Don't leak rd_statlist when a relcache entry is dropped.
authorTom Lane <[email protected]>
Fri, 19 Mar 2021 00:37:09 +0000 (20:37 -0400)
committerTom Lane <[email protected]>
Fri, 19 Mar 2021 00:37:09 +0000 (20:37 -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 d353db40a20f6368b8789eb54637b7fa8fe534c4..a6f1f1f98a6a5ada81c9c20c74531b9d9f12d3cd 100644 (file)
@@ -2391,6 +2391,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);