8181170: resolved_references array leaks for RedefineClasses
Clear out resolved_reference from ClassLoaderData::_handles Reviewed-by: stefank, jiangli, sspitsyn
This commit is contained in:
parent
897a7b3f67
commit
8330d49736
@ -75,6 +75,9 @@
|
|||||||
#include "utilities/growableArray.hpp"
|
#include "utilities/growableArray.hpp"
|
||||||
#include "utilities/macros.hpp"
|
#include "utilities/macros.hpp"
|
||||||
#include "utilities/ostream.hpp"
|
#include "utilities/ostream.hpp"
|
||||||
|
#if INCLUDE_ALL_GCS
|
||||||
|
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
|
||||||
|
#endif // INCLUDE_ALL_GCS
|
||||||
#if INCLUDE_TRACE
|
#if INCLUDE_TRACE
|
||||||
#include "trace/tracing.hpp"
|
#include "trace/tracing.hpp"
|
||||||
#endif
|
#endif
|
||||||
@ -764,6 +767,25 @@ OopHandle ClassLoaderData::add_handle(Handle h) {
|
|||||||
return OopHandle(_handles.add(h()));
|
return OopHandle(_handles.add(h()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassLoaderData::remove_handle(OopHandle h) {
|
||||||
|
oop* ptr = h.ptr_raw();
|
||||||
|
if (ptr != NULL) {
|
||||||
|
assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
|
||||||
|
#if INCLUDE_ALL_GCS
|
||||||
|
// This barrier is used by G1 to remember the old oop values, so
|
||||||
|
// that we don't forget any objects that were live at the snapshot at
|
||||||
|
// the beginning.
|
||||||
|
if (UseG1GC) {
|
||||||
|
oop obj = *ptr;
|
||||||
|
if (obj != NULL) {
|
||||||
|
G1SATBCardTableModRefBS::enqueue(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*ptr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) {
|
void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) {
|
||||||
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
||||||
if (dest.resolve() != NULL) {
|
if (dest.resolve() != NULL) {
|
||||||
|
@ -364,6 +364,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
|||||||
const char* loader_name();
|
const char* loader_name();
|
||||||
|
|
||||||
OopHandle add_handle(Handle h);
|
OopHandle add_handle(Handle h);
|
||||||
|
void remove_handle(OopHandle h);
|
||||||
void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field
|
void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field
|
||||||
void add_class(Klass* k, bool publicize = true);
|
void add_class(Klass* k, bool publicize = true);
|
||||||
void remove_class(Klass* k);
|
void remove_class(Klass* k);
|
||||||
|
@ -89,8 +89,6 @@ ConstantPool::ConstantPool(Array<u1>* tags) :
|
|||||||
|
|
||||||
void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
|
void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
|
||||||
if (cache() != NULL) {
|
if (cache() != NULL) {
|
||||||
MetadataFactory::free_array<u2>(loader_data, reference_map());
|
|
||||||
set_reference_map(NULL);
|
|
||||||
MetadataFactory::free_metadata(loader_data, cache());
|
MetadataFactory::free_metadata(loader_data, cache());
|
||||||
set_cache(NULL);
|
set_cache(NULL);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "interpreter/interpreter.hpp"
|
#include "interpreter/interpreter.hpp"
|
||||||
#include "interpreter/rewriter.hpp"
|
#include "interpreter/rewriter.hpp"
|
||||||
#include "logging/log.hpp"
|
#include "logging/log.hpp"
|
||||||
|
#include "memory/metadataFactory.hpp"
|
||||||
#include "memory/metaspaceClosure.hpp"
|
#include "memory/metaspaceClosure.hpp"
|
||||||
#include "memory/resourceArea.hpp"
|
#include "memory/resourceArea.hpp"
|
||||||
#include "memory/universe.inline.hpp"
|
#include "memory/universe.inline.hpp"
|
||||||
@ -608,6 +609,14 @@ void ConstantPoolCache::initialize(const intArray& inverse_index_map,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConstantPoolCache::deallocate_contents(ClassLoaderData* data) {
|
||||||
|
assert(!is_shared(), "shared caches are not deallocated");
|
||||||
|
data->remove_handle(_resolved_references);
|
||||||
|
set_resolved_references(NULL);
|
||||||
|
MetadataFactory::free_array<u2>(data, _reference_map);
|
||||||
|
set_reference_map(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
#if INCLUDE_CDS_JAVA_HEAP
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
oop ConstantPoolCache::archived_references() {
|
oop ConstantPoolCache::archived_references() {
|
||||||
assert(UseSharedSpaces, "UseSharedSpaces expected.");
|
assert(UseSharedSpaces, "UseSharedSpaces expected.");
|
||||||
|
@ -510,9 +510,9 @@ class ConstantPoolCache: public MetaspaceObj {
|
|||||||
void dump_cache();
|
void dump_cache();
|
||||||
#endif // INCLUDE_JVMTI
|
#endif // INCLUDE_JVMTI
|
||||||
|
|
||||||
// Deallocate - no fields to deallocate
|
// RedefineClasses support
|
||||||
DEBUG_ONLY(bool on_stack() { return false; })
|
DEBUG_ONLY(bool on_stack() { return false; })
|
||||||
void deallocate_contents(ClassLoaderData* data) {}
|
void deallocate_contents(ClassLoaderData* data);
|
||||||
bool is_klass() const { return false; }
|
bool is_klass() const { return false; }
|
||||||
|
|
||||||
// Printing
|
// Printing
|
||||||
|
@ -46,6 +46,9 @@ public:
|
|||||||
OopHandle(oop* w) : _obj(w) {}
|
OopHandle(oop* w) : _obj(w) {}
|
||||||
|
|
||||||
oop resolve() const { return (_obj == NULL) ? (oop)NULL : *_obj; }
|
oop resolve() const { return (_obj == NULL) ? (oop)NULL : *_obj; }
|
||||||
|
|
||||||
|
// Used only for removing handle.
|
||||||
|
oop* ptr_raw() { return _obj; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARE_VM_OOPS_OOPHANDLE_HPP
|
#endif // SHARE_VM_OOPS_OOPHANDLE_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user