[Gdal-dev] Memory leak? How to release GDAL datasets?

Frank Warmerdam warmerdam at pobox.com
Mon Dec 18 03:41:32 EST 2006


Craig Miller wrote:
> Frank,
> 
> Here is a bit more info:
> 
> I'm working on an old project and some of my project settings were messed up
> resulting in an old build of gdal getting used.  I'm no longer seeing the
> weird Ogrpolygon stuff.  Unfortunately, once I fixed that I'm seeing a few
> different potential problems.  Here is the call stack and Data for the first
> two.
...
> Call Stack:
>     c:\vault\gdal\port\cpl_vsisimple.cpp (343): VSIRealloc
>     c:\vault\gdal\port\cpl_conv.cpp (363): CPLRealloc
>     c:\vault\gdal\gcore\gdaldataset.cpp (180): GDALDataset::GDALDataset
>     c:\vault\gdal\gcore\gdalpamdataset.cpp (107):
> GDALPamDataset::GDALPamDataset
>     c:\vault\gdal\frmts\gtiff\geotiff.cpp (1580): GTiffDataset::GTiffDataset
>     c:\vault\gdal\frmts\gtiff\geotiff.cpp (2594): GTiffDataset::Open
>     c:\vault\gdal\gcore\gdaldataset.cpp (1714): GDALOpen
>     c:\vault\backroads\mapcanvas.cpp (104): CMapCanvas::Open
>  Data:
>     88 B5 5B 01    E0 BD 2B 04                                   ..[...+.
> ........

Craig,

The above is the array for the "open dataset list".  This is
normally deallocated when the last dataset is closed.  While this
list may be "grown" when a dataset is opened, it is not considered
to be owned by the dataset.

> ------------------
> Mapcanvas.cpp line 324 looks like this:
> switch (pBand->GetColorInterpretation())
> 
> I don't free the ColorInterpretation as I understand it to be owned by the
> band.
> 
>  Call Stack:
>     c:\vault\gdal\port\cpl_vsisimple.cpp (333): VSIMalloc
>     c:\vault\gdal\gcore\gdalrasterblock.cpp (433):
> GDALRasterBlock::Internalize
>     c:\vault\gdal\gcore\gdalrasterband.cpp (1150):
> GDALRasterBand::GetLockedBlockRef
>     c:\vault\gdal\gcore\rasterio.cpp (386): GDALRasterBand::IRasterIO
>     c:\vault\gdal\gcore\gdalrasterband.cpp (308): GDALRasterBand::RasterIO
>     c:\vault\backroads\mapcanvas.cpp (324): CMapCanvas::LoadMap

This has nothing to do with color interpretation.  It is basically the
memory for a block of image data in the cache, and it should be released
when the associated dataset is closed.  If not there could be a significant
memory leak and I'd appreciate details on how to reproduce it.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list