From: Paul Ramsey Date: Wed, 4 Mar 2015 19:49:36 +0000 (+0000) Subject: Be (slightly) more memory friendly when generating statistics X-Git-Tag: 2.2.0rc1~624 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cb2830e13d0d735850109628134e35a447d344b;p=postgis Be (slightly) more memory friendly when generating statistics git-svn-id: http://svn.osgeo.org/postgis/trunk@13303 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c index 4d2e187f8..a8829a837 100644 --- a/postgis/gserialized_estimate.c +++ b/postgis/gserialized_estimate.c @@ -1299,6 +1299,7 @@ compute_gserialized_stats_mode(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfu GBOX gbox; ND_BOX *nd_box; bool is_null; + bool is_copy; datum = fetchfunc(stats, i, &is_null); @@ -1312,6 +1313,7 @@ compute_gserialized_stats_mode(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfu /* Read the bounds from the gserialized. */ geom = (GSERIALIZED *)PG_DETOAST_DATUM(datum); + is_copy = VARATT_IS_EXTENDED(datum); if ( LW_FAILURE == gserialized_get_gbox_p(geom, &gbox) ) { /* Skip empties too. */ @@ -1363,6 +1365,10 @@ compute_gserialized_stats_mode(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfu /* Increment our "good feature" count */ notnull_cnt++; + + /* Free up memory if our sample geometry was copied */ + if ( is_copy ) + pfree(geom); /* Give backend a chance of interrupting us */ vacuum_delay_point();