From: Paul Ramsey Date: Tue, 23 Sep 2008 19:07:03 +0000 (+0000) Subject: Reduce p-i-p memory leak by 50% X-Git-Tag: 1.4.0b1~714 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05162d3ef78fbcad262003e19439e55bb7b4786d;p=postgis Reduce p-i-p memory leak by 50% git-svn-id: http://svn.osgeo.org/postgis/trunk@2993 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom_rtree.c b/lwgeom/lwgeom_rtree.c index e967b9215..81bf1afe6 100644 --- a/lwgeom/lwgeom_rtree.c +++ b/lwgeom/lwgeom_rtree.c @@ -422,7 +422,11 @@ RTREE_POLY_CACHE *retrieveCache(LWPOLY *poly, uchar *serializedPoly, if(lwgeom_size_poly(currentCache->poly) != length) { LWDEBUG(3, "Polygon size mismatch, creating new cache."); - + for(i = 0; i < currentCache->ringCount; i++) + { + freeTree(currentCache->ringIndices[i]); + } + lwfree(currentCache->ringIndices); lwfree(currentCache->poly); lwfree(currentCache); return createNewCache(poly, serializedPoly); @@ -435,6 +439,11 @@ RTREE_POLY_CACHE *retrieveCache(LWPOLY *poly, uchar *serializedPoly, { LWDEBUGF(3, "Polygon mismatch, creating new cache. %c, %c", a, b); + for(i = 0; i < currentCache->ringCount; i++) + { + freeTree(currentCache->ringIndices[i]); + } + lwfree(currentCache->ringIndices); lwfree(currentCache->poly); lwfree(currentCache); return createNewCache(poly, serializedPoly);