Don't leak rd_statlist when a relcache entry is dropped.
authorTom Lane
Fri, 19 Mar 2021 00:37:09 +0000 (20:37 -0400)
committerTom Lane
Fri, 19 Mar 2021 02:22:47 +0000 (22:22 -0400)
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

index 7ef510cd01b703c21a34928475437a8b30614e77..b0e06c037f440b275daf62fbe368f8a7cba51349 100644 (file)
@@ -2392,6 +2392,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_keyattr);
    bms_free(relation->rd_pkattr);