< prev index next >

src/hotspot/share/services/memoryPool.hpp

erik_version

roman_version

8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #ifndef SHARE_VM_SERVICES_MEMORYPOOL_HPP                                                                                             
25 #define SHARE_VM_SERVICES_MEMORYPOOL_HPP                                                                                             
26 
27 #include "memory/heap.hpp"                                                                                                           
                                                                                                                                     
28 #include "services/memoryUsage.hpp"                                                                                                  
29 #include "utilities/macros.hpp"                                                                                                      
30 
31 // A memory pool represents the memory area that the VM manages.                                                                     
32 // The Java virtual machine has at least one memory pool                                                                             
33 // and it may create or remove memory pools during execution.                                                                        
34 // A memory pool can belong to the heap or the non-heap memory.                                                                      
35 // A Java virtual machine may also have memory pools belonging to                                                                    
36 // both heap and non-heap memory.                                                                                                    
37 
38 // Forward declaration                                                                                                               
39 class MemoryManager;                                                                                                                 
40 class SensorInfo;                                                                                                                    
41 class ThresholdSupport;                                                                                                              
42 
43 class MemoryPool : public CHeapObj<mtInternal> {                                                                                     
44   friend class MemoryManager;                                                                                                        
45  public:                                                                                                                             
46   enum PoolType {                                                                                                                    

8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #ifndef SHARE_VM_SERVICES_MEMORYPOOL_HPP
25 #define SHARE_VM_SERVICES_MEMORYPOOL_HPP
26 
27 #include "memory/heap.hpp"
28 #include "oops/oop.hpp"
29 #include "services/memoryUsage.hpp"
30 #include "utilities/macros.hpp"
31 
32 // A memory pool represents the memory area that the VM manages.
33 // The Java virtual machine has at least one memory pool
34 // and it may create or remove memory pools during execution.
35 // A memory pool can belong to the heap or the non-heap memory.
36 // A Java virtual machine may also have memory pools belonging to
37 // both heap and non-heap memory.
38 
39 // Forward declaration
40 class MemoryManager;
41 class SensorInfo;
42 class ThresholdSupport;
43 
44 class MemoryPool : public CHeapObj<mtInternal> {
45   friend class MemoryManager;
46  public:
47   enum PoolType {

74   volatile instanceOop _memory_pool_obj;                                                                                             
75 
76   void add_manager(MemoryManager* mgr);                                                                                              
77 
78  public:                                                                                                                             
79   MemoryPool(const char* name,                                                                                                       
80              PoolType type,                                                                                                          
81              size_t init_size,                                                                                                       
82              size_t max_size,                                                                                                        
83              bool support_usage_threshold,                                                                                           
84              bool support_gc_threshold);                                                                                             
85 
86   const char* name()                       { return _name; }                                                                         
87   bool        is_heap()                    { return _type == Heap; }                                                                 
88   bool        is_non_heap()                { return _type == NonHeap; }                                                              
89   size_t      initial_size()   const       { return _initial_size; }                                                                 
90   int         num_memory_managers() const  { return _num_managers; }                                                                 
91   // max size could be changed                                                                                                       
92   virtual size_t max_size()    const       { return _max_size; }                                                                     
93 
94   bool is_pool(instanceHandle pool) { return (pool() == _memory_pool_obj); }                                                         
95 
96   bool available_for_allocation()   { return _available_for_allocation; }                                                            
97   bool set_available_for_allocation(bool value) {                                                                                    
98     bool prev = _available_for_allocation;                                                                                           
99     _available_for_allocation = value;                                                                                               
100     return prev;                                                                                                                     
101   }                                                                                                                                  
102 
103   MemoryManager* get_memory_manager(int index) {                                                                                     
104     assert(index >= 0 && index < _num_managers, "Invalid index");                                                                    
105     return _managers[index];                                                                                                         
106   }                                                                                                                                  
107 
108   // Records current memory usage if it's a peak usage                                                                               
109   void record_peak_memory_usage();                                                                                                   
110 
111   MemoryUsage get_peak_memory_usage() {                                                                                              
112     // check current memory usage first and then return peak usage                                                                   
113     record_peak_memory_usage();                                                                                                      

75   volatile instanceOop _memory_pool_obj;
76 
77   void add_manager(MemoryManager* mgr);
78 
79  public:
80   MemoryPool(const char* name,
81              PoolType type,
82              size_t init_size,
83              size_t max_size,
84              bool support_usage_threshold,
85              bool support_gc_threshold);
86 
87   const char* name()                       { return _name; }
88   bool        is_heap()                    { return _type == Heap; }
89   bool        is_non_heap()                { return _type == NonHeap; }
90   size_t      initial_size()   const       { return _initial_size; }
91   int         num_memory_managers() const  { return _num_managers; }
92   // max size could be changed
93   virtual size_t max_size()    const       { return _max_size; }
94 
95   bool is_pool(instanceHandle pool) { return oopDesc::equals(pool(), _memory_pool_obj); }
96 
97   bool available_for_allocation()   { return _available_for_allocation; }
98   bool set_available_for_allocation(bool value) {
99     bool prev = _available_for_allocation;
100     _available_for_allocation = value;
101     return prev;
102   }
103 
104   MemoryManager* get_memory_manager(int index) {
105     assert(index >= 0 && index < _num_managers, "Invalid index");
106     return _managers[index];
107   }
108 
109   // Records current memory usage if it's a peak usage
110   void record_peak_memory_usage();
111 
112   MemoryUsage get_peak_memory_usage() {
113     // check current memory usage first and then return peak usage
114     record_peak_memory_usage();
< prev index next >