< prev index next >

src/share/vm/services/mallocTracker.cpp

Print this page
rev 12121 : 8167650: NMT should check for invalid MEMFLAGS
Reviewed-by: dholmes, mockner


  38     amount += _malloc[index].malloc_size();
  39   }
  40   amount += _tracking_header.size() + total_arena();
  41   return amount;
  42 }
  43 
  44 // Total malloc'd memory used by arenas
  45 size_t MallocMemorySnapshot::total_arena() const {
  46   size_t amount = 0;
  47   for (int index = 0; index < mt_number_of_types; index ++) {
  48     amount += _malloc[index].arena_size();
  49   }
  50   return amount;
  51 }
  52 
  53 // Make adjustment by subtracting chunks used by arenas
  54 // from total chunks to get total free chunk size
  55 void MallocMemorySnapshot::make_adjustment() {
  56   size_t arena_size = total_arena();
  57   int chunk_idx = NMTUtil::flag_to_index(mtChunk);

  58   _malloc[chunk_idx].record_free(arena_size);
  59 }
  60 
  61 
  62 void MallocMemorySummary::initialize() {
  63   assert(sizeof(_snapshot) >= sizeof(MallocMemorySnapshot), "Sanity Check");
  64   // Uses placement new operator to initialize static area.
  65   ::new ((void*)_snapshot)MallocMemorySnapshot();
  66 }
  67 
  68 void MallocHeader::release() const {
  69   // Tracking already shutdown, no housekeeping is needed anymore
  70   if (MemTracker::tracking_level() <= NMT_minimal) return;
  71 
  72   MallocMemorySummary::record_free(size(), flags());
  73   MallocMemorySummary::record_free_malloc_header(sizeof(MallocHeader));
  74   if (MemTracker::tracking_level() == NMT_detail) {
  75     MallocSiteTable::deallocation_at(size(), _bucket_idx, _pos_idx);
  76   }
  77 }




  38     amount += _malloc[index].malloc_size();
  39   }
  40   amount += _tracking_header.size() + total_arena();
  41   return amount;
  42 }
  43 
  44 // Total malloc'd memory used by arenas
  45 size_t MallocMemorySnapshot::total_arena() const {
  46   size_t amount = 0;
  47   for (int index = 0; index < mt_number_of_types; index ++) {
  48     amount += _malloc[index].arena_size();
  49   }
  50   return amount;
  51 }
  52 
  53 // Make adjustment by subtracting chunks used by arenas
  54 // from total chunks to get total free chunk size
  55 void MallocMemorySnapshot::make_adjustment() {
  56   size_t arena_size = total_arena();
  57   int chunk_idx = NMTUtil::flag_to_index(mtChunk);
  58   assert(chunk_idx >= 0 && chunk_idx < mt_number_of_types, "Index out of bound.");
  59   _malloc[chunk_idx].record_free(arena_size);
  60 }
  61 
  62 
  63 void MallocMemorySummary::initialize() {
  64   assert(sizeof(_snapshot) >= sizeof(MallocMemorySnapshot), "Sanity Check");
  65   // Uses placement new operator to initialize static area.
  66   ::new ((void*)_snapshot)MallocMemorySnapshot();
  67 }
  68 
  69 void MallocHeader::release() const {
  70   // Tracking already shutdown, no housekeeping is needed anymore
  71   if (MemTracker::tracking_level() <= NMT_minimal) return;
  72 
  73   MallocMemorySummary::record_free(size(), flags());
  74   MallocMemorySummary::record_free_malloc_header(sizeof(MallocHeader));
  75   if (MemTracker::tracking_level() == NMT_detail) {
  76     MallocSiteTable::deallocation_at(size(), _bucket_idx, _pos_idx);
  77   }
  78 }


< prev index next >