Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/services/gcNotifier.cpp
          +++ new/src/share/vm/services/gcNotifier.cpp
↓ open down ↓ 92 lines elided ↑ open up ↑
  93   93                            CHECK_NH);
  94   94    return Handle(THREAD,(oop)result.get_jobject());
  95   95  
  96   96  }
  97   97  
  98   98  static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TRAPS) {
  99   99  
 100  100    // Fill the arrays of MemoryUsage objects with before and after GC
 101  101    // per pool memory usage
 102  102  
 103      -  klassOop muKlass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);   objArrayOop bu = oopFactory::new_objArray( muKlass,MemoryService::num_memory_pools(), CHECK_NH);
      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);
 104  111    objArrayHandle usage_before_gc_ah(THREAD, bu);
 105      -  objArrayOop au = oopFactory::new_objArray(muKlass,MemoryService::num_memory_pools(), CHECK_NH);
      112 +  objArrayOop au = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
 106  113    objArrayHandle usage_after_gc_ah(THREAD, au);
 107  114  
 108  115    for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
 109  116      Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
 110  117      Handle after_usage;
 111  118  
 112  119      MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
 113  120      if (u.max_size() == 0 && u.used() > 0) {
 114  121        // If max size == 0, this pool is a survivor space.
 115  122        // Set max size = -1 since the pools will be swapped after GC.
↓ open down ↓ 101 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX