提交 c78ca104 编写于 作者: D dsamersoff

7066129: GarbageCollectorMXBean#getLastGcInfo leaks native memory

Summary: Make GCStatInfo a resource object
Reviewed-by: phh, coleenp
上级 83682f21
......@@ -44,7 +44,8 @@ void GCNotifier::pushNotification(GCMemoryManager *mgr, const char *action, cons
// Make a copy of the last GC statistics
// GC may occur between now and the creation of the notification
int num_pools = MemoryService::num_memory_pools();
GCStatInfo* stat = new GCStatInfo(num_pools);
// stat is deallocated inside GCNotificationRequest
GCStatInfo* stat = new(ResourceObj::C_HEAP) GCStatInfo(num_pools);
mgr->get_last_gc_stat(stat);
GCNotificationRequest *request = new GCNotificationRequest(os::javaTimeMillis(),mgr,action,cause,stat);
addRequest(request);
......
......@@ -2047,15 +2047,15 @@ JVM_ENTRY(void, jmm_GetLastGCStat(JNIEnv *env, jobject obj, jmmGCStat *gc_stat))
// Make a copy of the last GC statistics
// GC may occur while constructing the last GC information
int num_pools = MemoryService::num_memory_pools();
GCStatInfo* stat = new GCStatInfo(num_pools);
if (mgr->get_last_gc_stat(stat) == 0) {
GCStatInfo stat(num_pools);
if (mgr->get_last_gc_stat(&stat) == 0) {
gc_stat->gc_index = 0;
return;
}
gc_stat->gc_index = stat->gc_index();
gc_stat->start_time = Management::ticks_to_ms(stat->start_time());
gc_stat->end_time = Management::ticks_to_ms(stat->end_time());
gc_stat->gc_index = stat.gc_index();
gc_stat->start_time = Management::ticks_to_ms(stat.start_time());
gc_stat->end_time = Management::ticks_to_ms(stat.end_time());
// Current implementation does not have GC extension attributes
gc_stat->num_gc_ext_attributes = 0;
......@@ -2073,17 +2073,17 @@ JVM_ENTRY(void, jmm_GetLastGCStat(JNIEnv *env, jobject obj, jmmGCStat *gc_stat))
objArrayHandle usage_after_gc_ah(THREAD, au);
for (int i = 0; i < num_pools; i++) {
Handle before_usage = MemoryService::create_MemoryUsage_obj(stat->before_gc_usage_for_pool(i), CHECK);
Handle before_usage = MemoryService::create_MemoryUsage_obj(stat.before_gc_usage_for_pool(i), CHECK);
Handle after_usage;
MemoryUsage u = stat->after_gc_usage_for_pool(i);
MemoryUsage u = stat.after_gc_usage_for_pool(i);
if (u.max_size() == 0 && u.used() > 0) {
// If max size == 0, this pool is a survivor space.
// Set max size = -1 since the pools will be swapped after GC.
MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK);
} else {
after_usage = MemoryService::create_MemoryUsage_obj(stat->after_gc_usage_for_pool(i), CHECK);
after_usage = MemoryService::create_MemoryUsage_obj(stat.after_gc_usage_for_pool(i), CHECK);
}
usage_before_gc_ah->obj_at_put(i, before_usage());
usage_after_gc_ah->obj_at_put(i, after_usage());
......
......@@ -214,8 +214,8 @@ GCMemoryManager::~GCMemoryManager() {
void GCMemoryManager::initialize_gc_stat_info() {
assert(MemoryService::num_memory_pools() > 0, "should have one or more memory pools");
_last_gc_stat = new GCStatInfo(MemoryService::num_memory_pools());
_current_gc_stat = new GCStatInfo(MemoryService::num_memory_pools());
_last_gc_stat = new(ResourceObj::C_HEAP) GCStatInfo(MemoryService::num_memory_pools());
_current_gc_stat = new(ResourceObj::C_HEAP) GCStatInfo(MemoryService::num_memory_pools());
// tracking concurrent collections we need two objects: one to update, and one to
// hold the publicly available "last (completed) gc" information.
}
......
......@@ -108,7 +108,7 @@ public:
const char* name() { return "CodeCacheManager"; }
};
class GCStatInfo : public CHeapObj {
class GCStatInfo : public ResourceObj {
private:
size_t _index;
jlong _start_time;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册