From 967b693eaef10aab76038163c6abd5778db38c51 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 18 Mar 2021 20:37:09 -0400 Subject: [PATCH] Don't leak rd_statlist when a relcache entry is dropped. Although these lists are usually NIL, and even when not empty are unlikely to be large, constant relcache update traffic could eventually result in visible bloat of CacheMemoryContext. Found via valgrind testing. Back-patch to v10 where this field was added. Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us --- src/backend/utils/cache/relcache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index e29efa10239..e516012c17c 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -2268,6 +2268,7 @@ RelationDestroyRelation(Relation relation, bool remember_tupdesc) FreeTriggerDesc(relation->trigdesc); list_free_deep(relation->rd_fkeylist); list_free(relation->rd_indexlist); + list_free(relation->rd_statlist); bms_free(relation->rd_indexattr); bms_free(relation->rd_projindexattr); bms_free(relation->rd_keyattr);