< prev index next >

src/hotspot/share/gc/g1/g1MemoryPool.hpp

Print this page


   1 /*
   2  * Copyright (c) 2007, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1MEMORYPOOL_HPP
  26 #define SHARE_VM_GC_G1_G1MEMORYPOOL_HPP
  27 
  28 #include "gc/g1/g1MonitoringSupport.hpp"
  29 #include "services/memoryPool.hpp"
  30 #include "services/memoryUsage.hpp"
  31 
  32 // This file contains the three classes that represent the memory
  33 // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and
  34 // G1OldGenPool. In G1, unlike our other GCs, we do not have a
  35 // physical space for each of those spaces. Instead, we allocate
  36 // regions for all three spaces out of a single pool of regions (that
  37 // pool basically covers the entire heap). As a result, the eden,
  38 // survivor, and old gen are considered logical spaces in G1, as each
  39 // is a set of non-contiguous regions. This is also reflected in the
  40 // way we map them to memory pools here. The easiest way to have done
  41 // this would have been to map the entire G1 heap to a single memory
  42 // pool. However, it's helpful to show how large the eden and survivor
  43 // get, as this does affect the performance and behavior of G1. Which
  44 // is why we introduce the three memory pools implemented here.
  45 //
  46 // See comments in g1MonitoringSupport.hpp for additional details
  47 // on this model.






  48 //


  49 
  50 class G1CollectedHeap;
  51 
  52 // This class is shared by the three G1 memory pool classes
  53 // (G1EdenPool, G1SurvivorPool, G1OldGenPool).
  54 class G1MemoryPoolSuper : public CollectedMemoryPool {
  55 protected:
  56   G1MonitoringSupport* _g1mm;
  57 
  58   // Would only be called from subclasses.
  59   G1MemoryPoolSuper(G1CollectedHeap* g1h,
  60                     const char* name,
  61                     size_t init_size,
  62                     size_t max_size,
  63                     bool support_usage_threshold);
  64 };
  65 
  66 // Memory pool that represents the G1 eden.




  67 class G1EdenPool : public G1MemoryPoolSuper {
  68 public:
  69   G1EdenPool(G1CollectedHeap* g1h, size_t initial_size);
  70 
  71   size_t used_in_bytes() { return _g1mm->eden_space_used(); }
  72 
  73   MemoryUsage get_memory_usage();
  74 };
  75 
  76 // Memory pool that represents the G1 survivor.
  77 class G1SurvivorPool : public G1MemoryPoolSuper {
  78 public:
  79   G1SurvivorPool(G1CollectedHeap* g1h, size_t initial_size);
  80 
  81   size_t used_in_bytes() { return _g1mm->survivor_space_used(); }
  82 
  83   MemoryUsage get_memory_usage();
  84 };
  85 
  86 // Memory pool that represents the G1 old gen.
  87 class G1OldGenPool : public G1MemoryPoolSuper {

  88 public:
  89   G1OldGenPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size);



  90 
  91   size_t used_in_bytes() { return _g1mm->old_gen_used(); }












  92 





  93   MemoryUsage get_memory_usage();
  94 };
  95 
  96 #endif // SHARE_VM_GC_G1_G1MEMORYPOOL_HPP
   1 /*
   2  * Copyright (c) 2007, 2018, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1MEMORYPOOL_HPP
  26 #define SHARE_VM_GC_G1_G1MEMORYPOOL_HPP
  27 
  28 #include "gc/g1/g1MonitoringSupport.hpp"
  29 #include "services/memoryPool.hpp"
  30 #include "services/memoryUsage.hpp"
  31 
  32 // This file contains definitions for two memory pool models for the G1 heap
  33 // spaces. Which to use is determined by the G1UseLegacyMonitoring switch.  If
  34 // true, we use a model that defines three pools, G1EdenPool, G1SurvivorPool
  35 // and G1OldPool. If false (the default), we use a more accurate model
  36 // that defines two additional pools, G1HumongousPool and G1ArchivePool.








  37 //
  38 // In G1, unlike our other GCs, we do not have a contiguous virtual address
  39 // space for each pool. The pools are logical spaces in G1, and each pool
  40 // consists of a non-contiguous region set allocated out of a single region
  41 // pool which covers the entire heap. This is also reflected in the way we
  42 // map them to memory pools here. The easiest way to have done this would
  43 // have been to map the entire G1 heap to a single memory pool. However, it
  44 // is helpful to show how large each space gets, as their sizes affect G1's
  45 // performance and behavior.
  46 //
  47 // See comments in g1MonitoringSupport.hpp for additional details on this
  48 // model.
  49 
  50 class G1CollectedHeap;
  51 
  52 // This class is shared by all G1 memory pool classes: G1EdenPool,
  53 // G1SurvivorPool, G1OldPool, G1HumongousPool, and G1ArchivePool
  54 class G1MemoryPoolSuper : public CollectedMemoryPool {
  55 protected:
  56   G1MonitoringSupport* _g1mm;
  57 
  58   // Would only be called from subclasses.
  59   G1MemoryPoolSuper(G1CollectedHeap* g1h,
  60                     const char* name,
  61                     size_t init_size,
  62                     size_t max_size,
  63                     bool support_usage_threshold);
  64 };
  65 
  66 // In legacy mode, G1EdenPool, G1SurvivorPool, and G1OldPool represent
  67 // the G1 memory pools, and G1OldPool includes regions occupied by
  68 // humongous and archive objects.
  69 
  70 // Memory pool that represents the G1 eden space
  71 class G1EdenPool : public G1MemoryPoolSuper {
  72 public:
  73   G1EdenPool(G1CollectedHeap* g1h, size_t initial_size);

  74   size_t used_in_bytes() { return _g1mm->eden_space_used(); }

  75   MemoryUsage get_memory_usage();
  76 };
  77 
  78 // Memory pool that represents the G1 survivor space
  79 class G1SurvivorPool : public G1MemoryPoolSuper {
  80 public:
  81   G1SurvivorPool(G1CollectedHeap* g1h, size_t initial_size);

  82   size_t used_in_bytes() { return _g1mm->survivor_space_used(); }

  83   MemoryUsage get_memory_usage();
  84 };
  85 
  86 // Memory pool that represents the G1 old generation (legacy)
  87 // or G1 old space (default)
  88 class G1OldPool : public G1MemoryPoolSuper {
  89 public:
  90   G1OldPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size);
  91   size_t used_in_bytes() { return _g1mm->old_space_used(); }
  92   MemoryUsage get_memory_usage();
  93 };
  94 
  95 // The default model includes the three legacy pools plus G1ArchivePool
  96 // and G1HumongousPool, and G1OldPool does not include regions occupied
  97 // by humongous and archive objects. Instead, humongous and archive
  98 // objects each get their own pool.
  99 
 100 // Memory pool that represents the G1 archive space. The archive space
 101 // contains read-only class metadata from the class data sharing archives.
 102 class G1ArchivePool : public G1MemoryPoolSuper {
 103 public:
 104   G1ArchivePool(G1CollectedHeap* g1h, size_t initial_size);
 105   size_t used_in_bytes() { return _g1mm->archive_space_used(); }
 106   MemoryUsage get_memory_usage();
 107 };
 108 
 109 // Memory pool that represents the G1 humongous space
 110 class G1HumongousPool : public G1MemoryPoolSuper {
 111 public:
 112   G1HumongousPool(G1CollectedHeap* g1h, size_t initial_size);
 113   size_t used_in_bytes() { return _g1mm->humongous_space_used(); }
 114   MemoryUsage get_memory_usage();
 115 };
 116 
 117 #endif // SHARE_VM_GC_G1_G1MEMORYPOOL_HPP
< prev index next >