< prev index next >

src/share/vm/services/memBaseline.cpp

Print this page
rev 9024 : 8218558: NMT stack traces in output should show mt component for virtual memory allocations
Reviewed-by: shade, stuefe, coleenp
   1 /*
   2  * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  46 int compare_virtual_memory_size(const VirtualMemoryAllocationSite& s1,
  47   const VirtualMemoryAllocationSite& s2) {
  48   if (s1.reserved() == s2.reserved()) {
  49     return 0;
  50   } else if (s1.reserved() > s2.reserved()) {
  51     return -1;
  52   } else {
  53     return 1;
  54   }
  55 }
  56 
  57 // Sort into allocation site addresses order for baseline comparison
  58 int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) {
  59   return s1.call_stack()->compare(*s2.call_stack());
  60 }
  61 
  62 // Sort into allocation site addresses and memory type order for baseline comparison
  63 int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) {
  64   int res = compare_malloc_site(s1, s2);
  65   if (res == 0) {
  66     res = (int)(s1.flags() - s2.flags());
  67   }
  68 
  69   return res;
  70 }
  71 
  72 int compare_virtual_memory_site(const VirtualMemoryAllocationSite& s1,
  73   const VirtualMemoryAllocationSite& s2) {
  74   return s1.call_stack()->compare(*s2.call_stack());
  75 }
  76 
  77 /*
  78  * Walker to walk malloc allocation site table
  79  */
  80 class MallocAllocationSiteWalker : public MallocSiteWalker {
  81  private:
  82   SortedLinkedList<MallocSite, compare_malloc_size> _malloc_sites;
  83   size_t         _count;
  84 
  85   // Entries in MallocSiteTable with size = 0 and count = 0,
  86   // when the malloc site is not longer there.


 192       MemTracker::tracking_level() == NMT_detail) {
 193     baseline_allocation_sites();
 194     _baseline_type = Detail_baselined;
 195   }
 196 
 197   return true;
 198 }
 199 
 200 int compare_allocation_site(const VirtualMemoryAllocationSite& s1,
 201   const VirtualMemoryAllocationSite& s2) {
 202   return s1.call_stack()->compare(*s2.call_stack());
 203 }
 204 
 205 bool MemBaseline::aggregate_virtual_memory_allocation_sites() {
 206   SortedLinkedList<VirtualMemoryAllocationSite, compare_allocation_site> allocation_sites;
 207 
 208   VirtualMemoryAllocationIterator itr = virtual_memory_allocations();
 209   const ReservedMemoryRegion* rgn;
 210   VirtualMemoryAllocationSite* site;
 211   while ((rgn = itr.next()) != NULL) {
 212     VirtualMemoryAllocationSite tmp(*rgn->call_stack());
 213     site = allocation_sites.find(tmp);
 214     if (site == NULL) {
 215       LinkedListNode<VirtualMemoryAllocationSite>* node =
 216         allocation_sites.add(tmp);
 217       if (node == NULL) return false;
 218       site = node->data();
 219     }
 220     site->reserve_memory(rgn->size());
 221     site->commit_memory(rgn->committed_size());
 222   }
 223 
 224   _virtual_memory_sites.move(&allocation_sites);
 225   return true;
 226 }
 227 
 228 MallocSiteIterator MemBaseline::malloc_sites(SortingOrder order) {
 229   assert(!_malloc_sites.is_empty(), "Not detail baseline");
 230   switch(order) {
 231     case by_size:
 232       malloc_sites_to_size_order();


   1 /*
   2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  46 int compare_virtual_memory_size(const VirtualMemoryAllocationSite& s1,
  47   const VirtualMemoryAllocationSite& s2) {
  48   if (s1.reserved() == s2.reserved()) {
  49     return 0;
  50   } else if (s1.reserved() > s2.reserved()) {
  51     return -1;
  52   } else {
  53     return 1;
  54   }
  55 }
  56 
  57 // Sort into allocation site addresses order for baseline comparison
  58 int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) {
  59   return s1.call_stack()->compare(*s2.call_stack());
  60 }
  61 
  62 // Sort into allocation site addresses and memory type order for baseline comparison
  63 int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) {
  64   int res = compare_malloc_site(s1, s2);
  65   if (res == 0) {
  66     res = (int)(s1.flag() - s2.flag());
  67   }
  68 
  69   return res;
  70 }
  71 
  72 int compare_virtual_memory_site(const VirtualMemoryAllocationSite& s1,
  73   const VirtualMemoryAllocationSite& s2) {
  74   return s1.call_stack()->compare(*s2.call_stack());
  75 }
  76 
  77 /*
  78  * Walker to walk malloc allocation site table
  79  */
  80 class MallocAllocationSiteWalker : public MallocSiteWalker {
  81  private:
  82   SortedLinkedList<MallocSite, compare_malloc_size> _malloc_sites;
  83   size_t         _count;
  84 
  85   // Entries in MallocSiteTable with size = 0 and count = 0,
  86   // when the malloc site is not longer there.


 192       MemTracker::tracking_level() == NMT_detail) {
 193     baseline_allocation_sites();
 194     _baseline_type = Detail_baselined;
 195   }
 196 
 197   return true;
 198 }
 199 
 200 int compare_allocation_site(const VirtualMemoryAllocationSite& s1,
 201   const VirtualMemoryAllocationSite& s2) {
 202   return s1.call_stack()->compare(*s2.call_stack());
 203 }
 204 
 205 bool MemBaseline::aggregate_virtual_memory_allocation_sites() {
 206   SortedLinkedList<VirtualMemoryAllocationSite, compare_allocation_site> allocation_sites;
 207 
 208   VirtualMemoryAllocationIterator itr = virtual_memory_allocations();
 209   const ReservedMemoryRegion* rgn;
 210   VirtualMemoryAllocationSite* site;
 211   while ((rgn = itr.next()) != NULL) {
 212     VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->flag());
 213     site = allocation_sites.find(tmp);
 214     if (site == NULL) {
 215       LinkedListNode<VirtualMemoryAllocationSite>* node =
 216         allocation_sites.add(tmp);
 217       if (node == NULL) return false;
 218       site = node->data();
 219     }
 220     site->reserve_memory(rgn->size());
 221     site->commit_memory(rgn->committed_size());
 222   }
 223 
 224   _virtual_memory_sites.move(&allocation_sites);
 225   return true;
 226 }
 227 
 228 MallocSiteIterator MemBaseline::malloc_sites(SortingOrder order) {
 229   assert(!_malloc_sites.is_empty(), "Not detail baseline");
 230   switch(order) {
 231     case by_size:
 232       malloc_sites_to_size_order();


< prev index next >