[Liblas-devel] Python memory usage issue
Howard Butler
hobu.inc at gmail.com
Fri Jan 21 09:36:50 EST 2011
On Jan 21, 2011, at 4:07 AM, Nicola Creati wrote:
> Hello,
> running this simple Python script you will find that you will soon get out of memory. (It works with any las files)
> Can someone explain why?
> Thanks,
>
> Nicola
>
>
> from liblas.file import File
> f = File('/Downloads/libLAS-1.6.0b3/test/data/1.1_1.las')
> for i in xrange(15000):
> temp = f.header.offset
Cache the header:
f = File('/Downloads/libLAS-1.6.0b3/test/data/1.1_1.las')
h = f.header
for i in xrange(15000):
temp = h.offset
As far as the reason why it runs out of memory? Bad design :) Putting the f.header call inside the inner loop means constructing a python header object every time. This was leaking header objects, and has been fixed in the main branch.
Thanks for the report,
Howard
More information about the Liblas-devel
mailing list