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

Lucena, Ivan ivan.lucena at pmldnet.com
Wed Apr 8 15:16:18 EDT 2009


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




More information about the gdal-dev mailing list