hotspot/src/share/vm/services/virtualMemoryTracker.cpp
changeset 27162 0a4a7276949b
parent 26149 dd15a4c3746b
child 31345 1bba15125d8d
equal deleted inserted replaced
27159:3d2543e475e4 27162:0a4a7276949b
   441 
   441 
   442 
   442 
   443 bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) {
   443 bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) {
   444   assert(_reserved_regions != NULL, "Sanity check");
   444   assert(_reserved_regions != NULL, "Sanity check");
   445   ThreadCritical tc;
   445   ThreadCritical tc;
   446   LinkedListNode<ReservedMemoryRegion>* head = _reserved_regions->head();
   446   // Check that the _reserved_regions haven't been deleted.
   447   while (head != NULL) {
   447   if (_reserved_regions != NULL) {
   448     const ReservedMemoryRegion* rgn = head->peek();
   448     LinkedListNode<ReservedMemoryRegion>* head = _reserved_regions->head();
   449     if (!walker->do_allocation_site(rgn)) {
   449     while (head != NULL) {
   450       return false;
   450       const ReservedMemoryRegion* rgn = head->peek();
   451     }
   451       if (!walker->do_allocation_site(rgn)) {
   452     head = head->next();
   452         return false;
   453   }
   453       }
       
   454       head = head->next();
       
   455     }
       
   456    }
   454   return true;
   457   return true;
   455 }
   458 }
   456 
   459 
   457 // Transition virtual memory tracking level.
   460 // Transition virtual memory tracking level.
   458 bool VirtualMemoryTracker::transition(NMT_TrackingLevel from, NMT_TrackingLevel to) {
   461 bool VirtualMemoryTracker::transition(NMT_TrackingLevel from, NMT_TrackingLevel to) {
   459   if (from == NMT_minimal) {
   462   assert (from != NMT_minimal, "cannot convert from the lowest tracking level to anything");
   460     assert(to == NMT_summary || to == NMT_detail, "Just check");
   463   if (to == NMT_minimal) {
   461     VirtualMemorySummary::reset();
       
   462   } else if (to == NMT_minimal) {
       
   463     assert(from == NMT_summary || from == NMT_detail, "Just check");
   464     assert(from == NMT_summary || from == NMT_detail, "Just check");
   464     // Clean up virtual memory tracking data structures.
   465     // Clean up virtual memory tracking data structures.
   465     ThreadCritical tc;
   466     ThreadCritical tc;
       
   467     // Check for potential race with other thread calling transition
   466     if (_reserved_regions != NULL) {
   468     if (_reserved_regions != NULL) {
   467       delete _reserved_regions;
   469       delete _reserved_regions;
   468       _reserved_regions = NULL;
   470       _reserved_regions = NULL;
   469     }
   471     }
   470   }
   472   }