[postgis-devel] Re: [geos-devel] Finding the Leak

Mateusz Loskot mateusz at loskot.net
Tue Aug 19 04:30:32 PDT 2008


Paul Ramsey wrote:
> I had a few spare minutes today and poked around the area of the
> biggest leak...
> 
> I see this construct in the PostGIS side in get_prepared_geometry_cache
> 
> 		if ( !cache->prepared_geom )
> 		{
> 			LWDEBUGF(3, "get_prepared_geometry_cache: preparing obj");
> 			
> 			g = POSTGIS2GEOS( serialized_geom);
> 			cache->prepared_geom = GEOSPrepare( g);
> 		}
> 
> So, a GEOS geometry is being created, and then converted into a
> prepared geometry, but *not* destroyed.  Attempting to destroy the
> geometry right away leads to a crash, presumably because the
> PreparedGeometry contains a reference to it in baseGeom?
> 
> Later in the life cycle, the prepared geometry gets destroyed,
> 
> 		GEOSPreparedGeom_destroy( cache->prepared_geom);
> 
> But, in the PreparedGeometry destructor, the baseGeom is not destroyed...
> 
> PreparedPolygon::
> ~PreparedPolygon( )
> {
>         delete segIntFinder;
>         delete ptOnGeomLoc;
> 
>         for ( size_t i = 0, ni = segStrings.size(); i < ni; i++ )
>         {
>                 delete segStrings[ i ]->getCoordinates();
>                 delete segStrings[ i ];
>         }
> }
> 
> I guess this makes sense (not to always destroy the base geometry in
> the GEOS code), but in our code that means the geometry is allocated
> but not destroyed, yes?
> 
> Can saner heads than me confirm my analysis?




Folks,

Looks like the discussion moved completely to geos-devel list, so here
is the pointer for those who are interested:

http://lists.osgeo.org/pipermail/geos-devel/2008-August/thread.html

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org



More information about the postgis-devel mailing list