[Gdal-dev] Free SRSs allocated with OGRSFDriverRegistrar::Open?

Craig Miller craig.miller at spatialminds.com
Mon Oct 23 17:14:53 EDT 2006


In an ongoing effort to remove memory leaks and better understand GDAL/OGRs
memory management I'm still observing quite a few leaks.  Is there a global
command to free random SRS related info that gets allocated as a normal part
of using OGR?  I thought I saw one when browsing the class documentation the
other day, but I can't seem to locate it now.


I believe that I'm observing a memory leak when I allocate a Datsource with 

m_poDS = OGRSFDriverRegistrar::Open(...); 

and destroy it with: 

OGRDataSource::DestroyDataSource( m_poDS );
m_poDS =NULL;
    
The memory that is leaked when visually inspected seems to contain SRS
related information.  The call stack (below) confirms the same thing.  

c:\vault\gdal\port\cpl_vsisimple.cpp (343): VSIRealloc
c:\vault\gdal\port\cpl_conv.cpp (345): CPLRealloc
c:\vault\gdal\ogr\ogr_srsnode.cpp (324): OGR_SRSNode::InsertChild
c:\vault\gdal\ogr\ogr_srsnode.cpp (297): OGR_SRSNode::AddChild
c:\vault\gdal\ogr\ogr_srsnode.cpp (724): OGR_SRSNode::importFromWkt
c:\vault\gdal\ogr\ogr_srsnode.cpp (718): OGR_SRSNode::importFromWkt
c:\vault\gdal\ogr\ogrspatialreference.cpp (686):
OGRSpatialReference::importFromWkt
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpgdatasource.cpp (953):
OGRPGDataSource::FetchSRS
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpglayer.cpp (1051):
OGRPGLayer::GetSpatialRef
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpgtablelayer.cpp (1515):
OGRPGTableLayer::GetSpatialRef
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpgtablelayer.cpp (168):
OGRPGTableLayer::OGRPGTableLayer
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpgdatasource.cpp (529):
OGRPGDataSource::OpenTable
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpgdatasource.cpp (509):
OGRPGDataSource::Open
c:\vault\gdal\ogr\ogrsf_frmts\pg\ogrpgdriver.cpp (84): OGRPGDriver::Open
c:\vault\gdal\ogr\ogrsf_frmts\generic\ogrsfdriverregistrar.cpp (225):
OGRSFDriverRegistrar::Open




More information about the Gdal-dev mailing list