< prev index next >

src/share/vm/services/virtualMemoryTracker.hpp

Print this page
rev 12318 : 8167650: NMT should check for invalid MEMFLAGS
Reviewed-by: dholmes, mockner, cjplummer
   1 /*
   2  * Copyright (c) 2013, 2014, 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  *


  76   inline void commit_memory (size_t sz)  { data()->commit_memory(sz);   }
  77   inline void uncommit_memory(size_t sz) { data()->uncommit_memory(sz); }
  78   inline void release_memory(size_t sz)  { data()->release_memory(sz);  }
  79   inline size_t reserved() const  { return peek()->reserved(); }
  80   inline size_t committed() const { return peek()->committed(); }
  81 };
  82 
  83 class VirtualMemorySummary;
  84 
  85 // This class represents a snapshot of virtual memory at a given time.
  86 // The latest snapshot is saved in a static area.
  87 class VirtualMemorySnapshot : public ResourceObj {
  88   friend class VirtualMemorySummary;
  89 
  90  private:
  91   VirtualMemory  _virtual_memory[mt_number_of_types];
  92 
  93  public:
  94   inline VirtualMemory* by_type(MEMFLAGS flag) {
  95     int index = NMTUtil::flag_to_index(flag);

  96     return &_virtual_memory[index];
  97   }
  98 
  99   inline VirtualMemory* by_index(int index) {
 100     assert(index >= 0, "Index out of bound");
 101     assert(index < mt_number_of_types, "Index out of bound");
 102     return &_virtual_memory[index];
 103   }
 104 
 105   inline size_t total_reserved() const {
 106     size_t amount = 0;
 107     for (int index = 0; index < mt_number_of_types; index ++) {
 108       amount += _virtual_memory[index].reserved();
 109     }
 110     return amount;
 111   }
 112 
 113   inline size_t total_committed() const {
 114     size_t amount = 0;
 115     for (int index = 0; index < mt_number_of_types; index ++) {


   1 /*
   2  * Copyright (c) 2013, 2016, 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  *


  76   inline void commit_memory (size_t sz)  { data()->commit_memory(sz);   }
  77   inline void uncommit_memory(size_t sz) { data()->uncommit_memory(sz); }
  78   inline void release_memory(size_t sz)  { data()->release_memory(sz);  }
  79   inline size_t reserved() const  { return peek()->reserved(); }
  80   inline size_t committed() const { return peek()->committed(); }
  81 };
  82 
  83 class VirtualMemorySummary;
  84 
  85 // This class represents a snapshot of virtual memory at a given time.
  86 // The latest snapshot is saved in a static area.
  87 class VirtualMemorySnapshot : public ResourceObj {
  88   friend class VirtualMemorySummary;
  89 
  90  private:
  91   VirtualMemory  _virtual_memory[mt_number_of_types];
  92 
  93  public:
  94   inline VirtualMemory* by_type(MEMFLAGS flag) {
  95     int index = NMTUtil::flag_to_index(flag);
  96     assert(index >= 0 && index < mt_number_of_types, "Index out of bound.");
  97     return &_virtual_memory[index];
  98   }
  99 
 100   inline VirtualMemory* by_index(int index) {
 101     assert(index >= 0, "Index out of bound");
 102     assert(index < mt_number_of_types, "Index out of bound");
 103     return &_virtual_memory[index];
 104   }
 105 
 106   inline size_t total_reserved() const {
 107     size_t amount = 0;
 108     for (int index = 0; index < mt_number_of_types; index ++) {
 109       amount += _virtual_memory[index].reserved();
 110     }
 111     return amount;
 112   }
 113 
 114   inline size_t total_committed() const {
 115     size_t amount = 0;
 116     for (int index = 0; index < mt_number_of_types; index ++) {


< prev index next >