[gdal-dev] How to free memory allocated by ReadRaster, Python API

Even Rouault even.rouault at mines-paris.org
Wed Apr 8 16:44:34 EDT 2009


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