Don't leak rd_statlist when a relcache entry is dropped.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Mar 2021 00:37:09 +0000 (20:37 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
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 d0ad738c2400c8e40c2ecf5b4846d37a9518c8e6..c6e3dc30169d405a5ff88709e8bea3f882f868d0 100644 (file)
@@ -2348,6 +2348,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);