37 #include "services/memoryService.hpp" 38 #include "memoryManager.hpp" 39 #include "memory/oopFactory.hpp" 40 #include "memory/resourceArea.hpp" 41 42 GCNotificationRequest *GCNotifier::first_request = NULL; 43 GCNotificationRequest *GCNotifier::last_request = NULL; 44 45 void GCNotifier::pushNotification(GCMemoryManager *mgr, const char *action, const char *cause) { 46 // Make a copy of the last GC statistics 47 // GC may occur between now and the creation of the notification 48 int num_pools = MemoryService::num_memory_pools(); 49 // stat is deallocated inside GCNotificationRequest 50 GCStatInfo* stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(num_pools); 51 mgr->get_last_gc_stat(stat); 52 GCNotificationRequest *request = new GCNotificationRequest(os::javaTimeMillis(),mgr,action,cause,stat); 53 addRequest(request); 54 } 55 56 void GCNotifier::addRequest(GCNotificationRequest *request) { 57 MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); 58 if(first_request == NULL) { 59 first_request = request; 60 } else { 61 last_request->next = request; 62 } 63 last_request = request; 64 Service_lock->notify_all(); 65 } 66 67 GCNotificationRequest *GCNotifier::getRequest() { 68 MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); 69 GCNotificationRequest *request = first_request; 70 if(first_request != NULL) { 71 first_request = first_request->next; 72 } 73 return request; 74 } 75 76 bool GCNotifier::has_event() { 77 return first_request != NULL; 78 } 79 80 static Handle getGcInfoBuilder(GCMemoryManager *gcManager,TRAPS) { 81 82 Klass* gcMBeanKlass = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK_NH); 83 84 instanceOop i = gcManager->get_memory_manager_instance(THREAD); 85 instanceHandle ih(THREAD, i); 86 87 JavaValue result(T_OBJECT); 88 JavaCallArguments args(ih); | 37 #include "services/memoryService.hpp" 38 #include "memoryManager.hpp" 39 #include "memory/oopFactory.hpp" 40 #include "memory/resourceArea.hpp" 41 42 GCNotificationRequest *GCNotifier::first_request = NULL; 43 GCNotificationRequest *GCNotifier::last_request = NULL; 44 45 void GCNotifier::pushNotification(GCMemoryManager *mgr, const char *action, const char *cause) { 46 // Make a copy of the last GC statistics 47 // GC may occur between now and the creation of the notification 48 int num_pools = MemoryService::num_memory_pools(); 49 // stat is deallocated inside GCNotificationRequest 50 GCStatInfo* stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(num_pools); 51 mgr->get_last_gc_stat(stat); 52 GCNotificationRequest *request = new GCNotificationRequest(os::javaTimeMillis(),mgr,action,cause,stat); 53 addRequest(request); 54 } 55 56 void GCNotifier::addRequest(GCNotificationRequest *request) { 57 MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); 58 if(first_request == NULL) { 59 first_request = request; 60 } else { 61 last_request->next = request; 62 } 63 last_request = request; 64 Notification_lock->notify_all(); 65 } 66 67 GCNotificationRequest *GCNotifier::getRequest() { 68 MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); 69 GCNotificationRequest *request = first_request; 70 if(first_request != NULL) { 71 first_request = first_request->next; 72 } 73 return request; 74 } 75 76 bool GCNotifier::has_event() { 77 return first_request != NULL; 78 } 79 80 static Handle getGcInfoBuilder(GCMemoryManager *gcManager,TRAPS) { 81 82 Klass* gcMBeanKlass = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK_NH); 83 84 instanceOop i = gcManager->get_memory_manager_instance(THREAD); 85 instanceHandle ih(THREAD, i); 86 87 JavaValue result(T_OBJECT); 88 JavaCallArguments args(ih); |