From: Tom Lane Date: Thu, 19 Jan 2006 00:27:27 +0000 (+0000) Subject: Fix a tiny memory leak (one List header) in RelationCacheInvalidate(). X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=a5465fe02514b05458ba7b6099d4d52447b2b966;p=users%2Fbernd%2Fpostgres.git Fix a tiny memory leak (one List header) in RelationCacheInvalidate(). This is utterly insignificant in normal operation, but it becomes a problem during cache inval stress testing. The original coding in fact had no leak --- the 8.0 List rewrite created the issue. I wonder whether list_concat should pfree the discarded header? --- diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 06a75ffcaf..459014bd93 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -1786,8 +1786,6 @@ RelationCacheInvalidate(void) } } - rebuildList = list_concat(rebuildFirstList, rebuildList); - /* * Now zap any remaining smgr cache entries. This must happen before we * start to rebuild entries, since that may involve catalog fetches which @@ -1796,6 +1794,12 @@ RelationCacheInvalidate(void) smgrcloseall(); /* Phase 2: rebuild the items found to need rebuild in phase 1 */ + foreach(l, rebuildFirstList) + { + relation = (Relation) lfirst(l); + RelationClearRelation(relation, true); + } + list_free(rebuildFirstList); foreach(l, rebuildList) { relation = (Relation) lfirst(l);