RFR: 8340824: C2: Memory for TypeInterfaces not reclaimed by hashcons()

Roland Westrelin roland at openjdk.org
Tue Sep 24 15:58:08 UTC 2024


The list of interfaces for a TypeInterfaces is contained in a
GrowableArray that's allocated in the type arena. When hashcons()
deletes a TypeInterfaces object because an identical one exists, it
can't reclaim memory for the object because it can only free the last
thing that was allocated and that's the backing store for the
GrowableArray, not the TypeInterfaces object.

With this patch, when the destructor of a GrowableArray is called, an
attempt is made to free memory for the backing store when it's
allocated in an arena. In the case of TypeInterfaces, for the
GrowableArray destructor to be called, I had to add a virtual
destructor to the base class (Type).

I noticed this while working on a fix for a separate issue that causes
more Type objects to be created. With that prototype fix,
TestScalarReplacementMaxLiveNodes uses 1.4GB of memory at peak. With
the patch I propose here on top, memory usage goes down to 150-200 MB
which is in line with the peak memory usage for
TestScalarReplacementMaxLiveNodes when run with current master.

-------------

Commit messages:
 - fix

Changes: https://git.openjdk.org/jdk/pull/21163/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21163&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8340824
  Stats: 7 lines in 2 files changed: 7 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/21163.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21163/head:pull/21163

PR: https://git.openjdk.org/jdk/pull/21163


More information about the hotspot-dev mailing list