src/share/vm/services/gcNotifier.cpp

Print this page




  83   instanceHandle ih(THREAD, i);
  84 
  85   JavaValue result(T_OBJECT);
  86   JavaCallArguments args(ih);
  87 
  88   JavaCalls::call_virtual(&result,
  89                           gcMBeanKlass,
  90                           vmSymbols::getGcInfoBuilder_name(),
  91                           vmSymbols::getGcInfoBuilder_signature(),
  92                           &args,
  93                           CHECK_NH);
  94   return Handle(THREAD,(oop)result.get_jobject());
  95 
  96 }
  97 
  98 static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TRAPS) {
  99 
 100   // Fill the arrays of MemoryUsage objects with before and after GC
 101   // per pool memory usage
 102 
 103   klassOop muKlass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);   objArrayOop bu = oopFactory::new_objArray( muKlass,MemoryService::num_memory_pools(), CHECK_NH);







 104   objArrayHandle usage_before_gc_ah(THREAD, bu);
 105   objArrayOop au = oopFactory::new_objArray(muKlass,MemoryService::num_memory_pools(), CHECK_NH);
 106   objArrayHandle usage_after_gc_ah(THREAD, au);
 107 
 108   for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
 109     Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
 110     Handle after_usage;
 111 
 112     MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
 113     if (u.max_size() == 0 && u.used() > 0) {
 114       // If max size == 0, this pool is a survivor space.
 115       // Set max size = -1 since the pools will be swapped after GC.
 116       MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
 117       after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK_NH);
 118     } else {
 119         after_usage = MemoryService::create_MemoryUsage_obj(u, CHECK_NH);
 120     }
 121     usage_before_gc_ah->obj_at_put(i, before_usage());
 122     usage_after_gc_ah->obj_at_put(i, after_usage());
 123   }
 124 
 125   // Current implementation only has 1 attribute (number of GC threads)




  83   instanceHandle ih(THREAD, i);
  84 
  85   JavaValue result(T_OBJECT);
  86   JavaCallArguments args(ih);
  87 
  88   JavaCalls::call_virtual(&result,
  89                           gcMBeanKlass,
  90                           vmSymbols::getGcInfoBuilder_name(),
  91                           vmSymbols::getGcInfoBuilder_signature(),
  92                           &args,
  93                           CHECK_NH);
  94   return Handle(THREAD,(oop)result.get_jobject());
  95 
  96 }
  97 
  98 static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TRAPS) {
  99 
 100   // Fill the arrays of MemoryUsage objects with before and after GC
 101   // per pool memory usage
 102 
 103   klassOop mu_klass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
 104   instanceKlassHandle mu_kh(THREAD, mu_klass);
 105 
 106   // The array allocations should use a handle containing mu_klass
 107   // as the first allocation could trigger a GC, causing the actual
 108   // klass oop to move, and leaving mu_klass pointing to the old
 109   // location.
 110   objArrayOop bu = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
 111   objArrayHandle usage_before_gc_ah(THREAD, bu);
 112   objArrayOop au = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
 113   objArrayHandle usage_after_gc_ah(THREAD, au);
 114 
 115   for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
 116     Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
 117     Handle after_usage;
 118 
 119     MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
 120     if (u.max_size() == 0 && u.used() > 0) {
 121       // If max size == 0, this pool is a survivor space.
 122       // Set max size = -1 since the pools will be swapped after GC.
 123       MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
 124       after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK_NH);
 125     } else {
 126         after_usage = MemoryService::create_MemoryUsage_obj(u, CHECK_NH);
 127     }
 128     usage_before_gc_ah->obj_at_put(i, before_usage());
 129     usage_after_gc_ah->obj_at_put(i, after_usage());
 130   }
 131 
 132   // Current implementation only has 1 attribute (number of GC threads)