The lifecycle of CDS dump-time data structures such as DumpTimeClassInfo and DumpTimeLambdaProxyClassInfo is not properly managed today, causing memory leak in certain cases.
We need to implement copy constructors, assignment operators, and destructors in order to work with collections such as ResourceHashtable and GrowableArray.
========================
[1] When cloning the _dumptime_table, etc, we use DumpTimeClassInfo::clone() to make deep copies of the DumpTimeClassInfo objects. However, when the cloned table is freed, the deep copies are not freed properly, leading to memory leak.
https://github.com/openjdk/jdk/blob/348a0521e1cd602c4093955310f838cf4ce4daae/src/hotspot/share/classfile/systemDictionaryShared.cpp#L1487
https://github.com/openjdk/jdk/blob/348a0521e1cd602c4093955310f838cf4ce4daae/src/hotspot/share/cds/dumpTimeClassInfo.cpp#L34
[2] When a DumpTimeClassInfo is freed, the deallocation of its internal fields is done in the wrong place ( SystemDictionaryShared::remove_dumptime_info). This should be done inside the DumpTimeClassInfo destructor instead.
https://github.com/openjdk/jdk/blob/348a0521e1cd602c4093955310f838cf4ce4daae/src/hotspot/share/classfile/systemDictionaryShared.cpp#L516
We need to implement copy constructors, assignment operators, and destructors in order to work with collections such as ResourceHashtable and GrowableArray.
========================
[1] When cloning the _dumptime_table, etc, we use DumpTimeClassInfo::clone() to make deep copies of the DumpTimeClassInfo objects. However, when the cloned table is freed, the deep copies are not freed properly, leading to memory leak.
https://github.com/openjdk/jdk/blob/348a0521e1cd602c4093955310f838cf4ce4daae/src/hotspot/share/classfile/systemDictionaryShared.cpp#L1487
https://github.com/openjdk/jdk/blob/348a0521e1cd602c4093955310f838cf4ce4daae/src/hotspot/share/cds/dumpTimeClassInfo.cpp#L34
[2] When a DumpTimeClassInfo is freed, the deallocation of its internal fields is done in the wrong place ( SystemDictionaryShared::remove_dumptime_info). This should be done inside the DumpTimeClassInfo destructor instead.
https://github.com/openjdk/jdk/blob/348a0521e1cd602c4093955310f838cf4ce4daae/src/hotspot/share/classfile/systemDictionaryShared.cpp#L516