[gdal-dev] How to free memory allocated by ReadRaster, Python API
Ivan Lucena
ivan.lucena at pmldnet.com
Wed Apr 8 17:31:59 EDT 2009
Hi Even,
D'accord. Good tip.
Although I am planning to read a relative large number of bands (temporal series) I can probably
enlarge my query windows and balance the memory load that it will take. I would do that if I was
developing some kind of application. The thing is that Python + GDAL + numpy is a wonderful data
exploration lab and that is all that I am doing in that case.
But about your previous reply, I am far from that machine now but I am almost sure that am using the
latest 'and greatest' trunk code. But I probably should run the setup.py again and re-install the
extension, right?
My best regards,
Ivan
Even Rouault wrote:
> And I forgot to mention that if you need to operate on big images, you'll have
> probably suboptimal/poor performance by just extracting one pixel at a time,
> as there's a non neglectable overhead for each binding function call,
> especially that one. I'd advise you to read bigger chunks at once, and then
> iterate on the result buffer.
>
> Le Wednesday 08 April 2009 21:16:18 Lucena, Ivan, vous avez écrit :
>> Hi,
>>
>> I have a small Python script that uses ReadRaster to collect some values in
>> order to do some math.
>>
>> The problem is that once I run the script through a Python IDE I can see
>> the memory usage increasing but it does not decrease at the end.
>>
>> After some runs I got a out of memory crash on the IDE itself (PythonWin).
>>
>> My code is something like that:
>>
>> {{{
>>
>> for b in range(nbands):
>> for yoff in range(ysize):
>> for xoff in range(xsize):
>> buffer = ds.ReadRaster(xoff,yoff,1,1,1,1,datatype,range(1,1+nbands)
>> #
>> # formulas and numpy calls
>> #
>> buffer = None
>>
>> ds = None
>>
>> }}}
>>
>> I am running with all my formulas commented just to isolate the memory
>> problem. It just reads and does nothing.
>>
>> Does anybody has any advise on how to free that buffer?
>>
>> Thanks in advance,
>>
>> Regards,
>>
>> Ivan
>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>
More information about the gdal-dev
mailing list