diff --git a/src/share/vm/classfile/classLoaderData.cpp b/src/share/vm/classfile/classLoaderData.cpp index 5336b44d0e48d9624bbd064e46ff0bfb0762d946..1f25e15ee9f18737d9f5ffeeb6c17cd5b22847c7 100644 --- a/src/share/vm/classfile/classLoaderData.cpp +++ b/src/share/vm/classfile/classLoaderData.cpp @@ -318,10 +318,6 @@ void ClassLoaderData::unload() { } tty->print_cr("]"); } - - // In some rare cases items added to this list will not be freed elsewhere. - // To keep it simple, just free everything in it here. - free_deallocate_list(); } oop ClassLoaderData::keep_alive_object() const { @@ -817,6 +813,12 @@ void ClassLoaderDataGraph::free_deallocate_lists() { // called on all alive classes. See the comment in ClassLoaderDataGraph::clean_metaspaces. cld->free_deallocate_list(); } + + // In some rare cases items added to the unloading list will not be freed elsewhere. + // To keep it simple, walk the _unloading list also. + for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) { + cld->free_deallocate_list(); + } } // CDS support