[Gdal-dev] Forgetting to Destroy?

Frank Warmerdam warmerdam at pobox.com
Thu Dec 11 14:11:40 EST 2003


Curt Mills, WE7U wrote:
> My code is currently reading Shapefile maps via OGR.  If I disable
> the feature loop, memory appears relatively stable.
> 
> Enabling the feature loop, I'm losing megabytes every time I read
> in Shapefiles.  I disabled the majority of the "feature" loop via
> #ifdef's, and am just running this now:
> 
> 
>   while ( (featureH = OGR_L_GetNextFeature( layer )) != NULL ) {
>       if (featureH)
>           OGR_F_Destroy( featureH );
>   }
> 
> 
> It's still losing megabytes every time I load a map.  Using CVS
> GDAL/OGR and of course the 'C' API.
> 
> Is OGR_F_Destroy() not free'ing all the memory used?
> 
> I register all drivers when I start my app (a long-running app by
> the way), and leave them alone after that.  Is there something that
> I should Destory/Free regarding the drivers?
> 
> I'm not free'ing the layers either, but it appears from your 'C'
> sample program that I should not.  There doesn't appear to be a big
> problem in the layers anyway.

Curt,

I ran "ogrinfo -ro -al polygon.shp" through valgrind, and it reports only
316 bytes of memory leaked.  Is there anything unusual about the file
in question?  Are you working from recent source?  I don't know why there
would be a problem.  You are destroying the datasource when you are done,
right?

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    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list