RFR: JDK-8298084: Memory leak in Method::build_profiling_method_data

Coleen Phillimore coleenp at openjdk.org
Wed Dec 7 02:58:07 UTC 2022


On Wed, 7 Dec 2022 02:22:30 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Resolve memory leak related to `MethodData::_extra_data_lock` in `Method::build_profiling_method_data` by defining `MethodData::release_C_heap_structures` and calling it where appropriate before deallocating `MethodData`.
>
> src/hotspot/share/oops/methodData.cpp line 1826:
> 
>> 1824: 
>> 1825: void MethodData::deallocate_contents(ClassLoaderData* loader_data) {
>> 1826:   assert(_extra_data_lock == NULL, "memory leak");
> 
> I don't know why you didn't make deallocate_contents call release_C_heap_structures, like the other metadata deallocate_contents functions do?

I see why.  InstanceKlass release_C_heap_structures is called for class unloading so frees everything in its tree, and deallocate_contents does the same thing except for the constant pool, because the ConstantPool deallocate_contents calls its own release_C_heap_structures.  Methods are attached to InstanceKlass so let InstanceKlass call release_C_heap_structures for them, except for this case that was added for MethodData here.

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

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


More information about the hotspot-dev mailing list