< prev index next >

src/hotspot/share/services/virtualMemoryTracker.hpp

Print this page
rev 57511 : [mq]: metaspace-improvement


  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  *
  23  */
  24 
  25 #ifndef SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
  26 #define SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
  27 
  28 #if INCLUDE_NMT
  29 
  30 #include "memory/allocation.hpp"
  31 #include "memory/metaspace.hpp"
  32 #include "services/allocationSite.hpp"
  33 #include "services/nmtCommon.hpp"
  34 #include "utilities/linkedlist.hpp"
  35 #include "utilities/nativeCallStack.hpp"
  36 #include "utilities/ostream.hpp"
  37 
  38 
  39 /*
  40  * Virtual memory counter
  41  */
  42 class VirtualMemory {
  43  private:
  44   size_t     _reserved;
  45   size_t     _committed;
  46 
  47  public:
  48   VirtualMemory() : _reserved(0), _committed(0) { }
  49 
  50   inline void reserve_memory(size_t sz) { _reserved += sz; }
  51   inline void commit_memory (size_t sz) {


 403   static bool add_committed_region      (address base_addr, size_t size, const NativeCallStack& stack);
 404   static bool remove_uncommitted_region (address base_addr, size_t size);
 405   static bool remove_released_region    (address base_addr, size_t size);
 406   static void set_reserved_region_type  (address addr, MEMFLAGS flag);
 407 
 408   // Walk virtual memory data structure for creating baseline, etc.
 409   static bool walk_virtual_memory(VirtualMemoryWalker* walker);
 410 
 411   static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to);
 412 
 413   // Snapshot current thread stacks
 414   static void snapshot_thread_stacks();
 415 
 416  private:
 417   static SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* _reserved_regions;
 418 };
 419 
 420 
 421 class MetaspaceSnapshot : public ResourceObj {
 422 private:
 423   size_t  _reserved_in_bytes[Metaspace::MetadataTypeCount];
 424   size_t  _committed_in_bytes[Metaspace::MetadataTypeCount];
 425   size_t  _used_in_bytes[Metaspace::MetadataTypeCount];
 426   size_t  _free_in_bytes[Metaspace::MetadataTypeCount];
 427 
 428 public:
 429   MetaspaceSnapshot();
 430   size_t reserved_in_bytes(Metaspace::MetadataType type)   const { assert_valid_metadata_type(type); return _reserved_in_bytes[type]; }
 431   size_t committed_in_bytes(Metaspace::MetadataType type)  const { assert_valid_metadata_type(type); return _committed_in_bytes[type]; }
 432   size_t used_in_bytes(Metaspace::MetadataType type)       const { assert_valid_metadata_type(type); return _used_in_bytes[type]; }
 433   size_t free_in_bytes(Metaspace::MetadataType type)       const { assert_valid_metadata_type(type); return _free_in_bytes[type]; }
 434 
 435   static void snapshot(MetaspaceSnapshot& s);
 436 
 437 private:
 438   static void snapshot(Metaspace::MetadataType type, MetaspaceSnapshot& s);
 439 
 440   static void assert_valid_metadata_type(Metaspace::MetadataType type) {
 441     assert(type == Metaspace::ClassType || type == Metaspace::NonClassType,
 442       "Invalid metadata type");
 443   }
 444 };
 445 
 446 #endif // INCLUDE_NMT
 447 
 448 #endif // SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP


  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  *
  23  */
  24 
  25 #ifndef SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
  26 #define SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
  27 
  28 #if INCLUDE_NMT
  29 
  30 #include "memory/allocation.hpp"
  31 #include "memory/metaspace/metaspaceEnums.hpp"
  32 #include "services/allocationSite.hpp"
  33 #include "services/nmtCommon.hpp"
  34 #include "utilities/linkedlist.hpp"
  35 #include "utilities/nativeCallStack.hpp"
  36 #include "utilities/ostream.hpp"
  37 
  38 
  39 /*
  40  * Virtual memory counter
  41  */
  42 class VirtualMemory {
  43  private:
  44   size_t     _reserved;
  45   size_t     _committed;
  46 
  47  public:
  48   VirtualMemory() : _reserved(0), _committed(0) { }
  49 
  50   inline void reserve_memory(size_t sz) { _reserved += sz; }
  51   inline void commit_memory (size_t sz) {


 403   static bool add_committed_region      (address base_addr, size_t size, const NativeCallStack& stack);
 404   static bool remove_uncommitted_region (address base_addr, size_t size);
 405   static bool remove_released_region    (address base_addr, size_t size);
 406   static void set_reserved_region_type  (address addr, MEMFLAGS flag);
 407 
 408   // Walk virtual memory data structure for creating baseline, etc.
 409   static bool walk_virtual_memory(VirtualMemoryWalker* walker);
 410 
 411   static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to);
 412 
 413   // Snapshot current thread stacks
 414   static void snapshot_thread_stacks();
 415 
 416  private:
 417   static SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* _reserved_regions;
 418 };
 419 
 420 
 421 class MetaspaceSnapshot : public ResourceObj {
 422 private:
 423   size_t  _reserved_in_bytes[metaspace::MetadataTypeCount];
 424   size_t  _committed_in_bytes[metaspace::MetadataTypeCount];
 425   size_t  _used_in_bytes[metaspace::MetadataTypeCount];
 426   size_t  _free_in_bytes[metaspace::MetadataTypeCount];
 427 
 428 public:
 429   MetaspaceSnapshot();
 430   size_t reserved_in_bytes(metaspace::MetadataType type)   const { assert_valid_metadata_type(type); return _reserved_in_bytes[type]; }
 431   size_t committed_in_bytes(metaspace::MetadataType type)  const { assert_valid_metadata_type(type); return _committed_in_bytes[type]; }
 432   size_t used_in_bytes(metaspace::MetadataType type)       const { assert_valid_metadata_type(type); return _used_in_bytes[type]; }
 433   size_t free_in_bytes(metaspace::MetadataType type)       const { assert_valid_metadata_type(type); return _free_in_bytes[type]; }
 434 
 435   static void snapshot(MetaspaceSnapshot& s);
 436 
 437 private:
 438   static void snapshot(metaspace::MetadataType type, MetaspaceSnapshot& s);
 439 
 440   static void assert_valid_metadata_type(metaspace::MetadataType type) {
 441     assert(type == metaspace::ClassType || type == metaspace::NonClassType,
 442       "Invalid metadata type");
 443   }
 444 };
 445 
 446 #endif // INCLUDE_NMT
 447 
 448 #endif // SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
< prev index next >