comparison src/share/vm/services/memoryManager.cpp @ 3356:78542e2b5e35

7036199: Adding a notification to the implementation of GarbageCollectorMXBeans Summary: Add a notification to the GarbageCollectorMXBeans Reviewed-by: acorn, mchung
author fparain
date Thu, 12 May 2011 10:30:11 -0700
parents 1d1603768966
children 436b4a3231bf
comparison
equal deleted inserted replaced
3355:f1cbbee6713b 3356:78542e2b5e35
31 #include "services/lowMemoryDetector.hpp" 31 #include "services/lowMemoryDetector.hpp"
32 #include "services/management.hpp" 32 #include "services/management.hpp"
33 #include "services/memoryManager.hpp" 33 #include "services/memoryManager.hpp"
34 #include "services/memoryPool.hpp" 34 #include "services/memoryPool.hpp"
35 #include "services/memoryService.hpp" 35 #include "services/memoryService.hpp"
36 #include "services/gcNotifier.hpp"
36 #include "utilities/dtrace.hpp" 37 #include "utilities/dtrace.hpp"
37 38
38 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__begin, char*, int, char*, int, 39 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__begin, char*, int, char*, int,
39 size_t, size_t, size_t, size_t); 40 size_t, size_t, size_t, size_t);
40 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__end, char*, int, char*, int, 41 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__end, char*, int, char*, int,
200 _num_collections = 0; 201 _num_collections = 0;
201 _last_gc_stat = NULL; 202 _last_gc_stat = NULL;
202 _last_gc_lock = new Mutex(Mutex::leaf, "_last_gc_lock", true); 203 _last_gc_lock = new Mutex(Mutex::leaf, "_last_gc_lock", true);
203 _current_gc_stat = NULL; 204 _current_gc_stat = NULL;
204 _num_gc_threads = 1; 205 _num_gc_threads = 1;
206 _notification_enabled = false;
205 } 207 }
206 208
207 GCMemoryManager::~GCMemoryManager() { 209 GCMemoryManager::~GCMemoryManager() {
208 delete _last_gc_stat; 210 delete _last_gc_stat;
209 delete _last_gc_lock; 211 delete _last_gc_lock;
248 // A collector MUST, even if it does not complete for some reason, 250 // A collector MUST, even if it does not complete for some reason,
249 // make a TraceMemoryManagerStats object where countCollection is true, 251 // make a TraceMemoryManagerStats object where countCollection is true,
250 // to ensure the current gc stat is placed in _last_gc_stat. 252 // to ensure the current gc stat is placed in _last_gc_stat.
251 void GCMemoryManager::gc_end(bool recordPostGCUsage, 253 void GCMemoryManager::gc_end(bool recordPostGCUsage,
252 bool recordAccumulatedGCTime, 254 bool recordAccumulatedGCTime,
253 bool recordGCEndTime, bool countCollection) { 255 bool recordGCEndTime, bool countCollection,
256 GCCause::Cause cause) {
254 if (recordAccumulatedGCTime) { 257 if (recordAccumulatedGCTime) {
255 _accumulated_timer.stop(); 258 _accumulated_timer.stop();
256 } 259 }
257 if (recordGCEndTime) { 260 if (recordGCEndTime) {
258 _current_gc_stat->set_end_time(Management::timestamp()); 261 _current_gc_stat->set_end_time(Management::timestamp());
280 MemoryUsage usage = pool->get_memory_usage(); 283 MemoryUsage usage = pool->get_memory_usage();
281 284
282 // Compare with GC usage threshold 285 // Compare with GC usage threshold
283 pool->set_last_collection_usage(usage); 286 pool->set_last_collection_usage(usage);
284 LowMemoryDetector::detect_after_gc_memory(pool); 287 LowMemoryDetector::detect_after_gc_memory(pool);
288 }
289 if(is_notification_enabled()) {
290 bool isMajorGC = this == MemoryService::get_major_gc_manager();
291 GCNotifier::pushNotification(this, isMajorGC ? "end of major GC" : "end of minor GC",
292 GCCause::to_string(cause));
285 } 293 }
286 } 294 }
287 if (countCollection) { 295 if (countCollection) {
288 _num_collections++; 296 _num_collections++;
289 // alternately update two objects making one public when complete 297 // alternately update two objects making one public when complete