8298084: Memory leak in Method::build_profiling_method_data

Co-authored-by: Justin King <jcking@openjdk.org>
Reviewed-by: kbarrett, eosterlund, dholmes, jcking, thartmann
This commit is contained in:
Coleen Phillimore 2022-12-13 13:02:23 +00:00
parent d453190300
commit 04b8d0cf5c
6 changed files with 38 additions and 18 deletions

View file

@ -595,10 +595,10 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
// Release C heap allocated data that this points to, which includes
// reference counting symbol names.
// Can't release the constant pool here because the constant pool can be
// deallocated separately from the InstanceKlass for default methods and
// redefine classes.
release_C_heap_structures(/* release_constant_pool */ false);
// Can't release the constant pool or MethodData C heap data here because the constant
// pool can be deallocated separately from the InstanceKlass for default methods and
// redefine classes. MethodData can also be released separately.
release_C_heap_structures(/* release_sub_metadata */ false);
deallocate_methods(loader_data, methods());
set_methods(NULL);
@ -2650,13 +2650,15 @@ static void method_release_C_heap_structures(Method* m) {
m->release_C_heap_structures();
}
// Called also by InstanceKlass::deallocate_contents, with false for release_constant_pool.
void InstanceKlass::release_C_heap_structures(bool release_constant_pool) {
// Called also by InstanceKlass::deallocate_contents, with false for release_sub_metadata.
void InstanceKlass::release_C_heap_structures(bool release_sub_metadata) {
// Clean up C heap
Klass::release_C_heap_structures();
// Deallocate and call destructors for MDO mutexes
methods_do(method_release_C_heap_structures);
if (release_sub_metadata) {
methods_do(method_release_C_heap_structures);
}
// Destroy the init_monitor
delete _init_monitor;
@ -2696,7 +2698,7 @@ void InstanceKlass::release_C_heap_structures(bool release_constant_pool) {
FREE_C_HEAP_ARRAY(char, _source_debug_extension);
if (release_constant_pool) {
if (release_sub_metadata) {
constants()->release_C_heap_structures();
}
}