< prev index next >

src/hotspot/share/services/memoryManager.hpp

erik_version

roman_version

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_MEMORYMANAGER_HPP                                                                                          
25 #define SHARE_VM_SERVICES_MEMORYMANAGER_HPP                                                                                          
26 
27 #include "gc/shared/gcCause.hpp"                                                                                                     
28 #include "memory/allocation.hpp"                                                                                                     
                                                                                                                                     
29 #include "oops/oopsHierarchy.hpp"                                                                                                    
30 #include "runtime/handles.hpp"                                                                                                       
31 #include "runtime/timer.hpp"                                                                                                         
32 #include "services/memoryUsage.hpp"                                                                                                  
33 
34 // A memory manager is responsible for managing one or more memory pools.                                                            
35 // The garbage collector is one type of memory managers responsible                                                                  
36 // for reclaiming memory occupied by unreachable objects.  A Java virtual                                                            
37 // machine may have one or more memory managers.   It may                                                                            
38 // add or remove memory managers during execution.                                                                                   
39 // A memory pool can be managed by more than one memory managers.                                                                    
40 
41 class MemoryPool;                                                                                                                    
42 class GCMemoryManager;                                                                                                               
43 class OopClosure;                                                                                                                    
44 
45 class MemoryManager : public CHeapObj<mtInternal> {                                                                                  
46 private:                                                                                                                             
47   enum {                                                                                                                             

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_MEMORYMANAGER_HPP
25 #define SHARE_VM_SERVICES_MEMORYMANAGER_HPP
26 
27 #include "gc/shared/gcCause.hpp"
28 #include "memory/allocation.hpp"
29 #include "oops/oop.hpp"
30 #include "oops/oopsHierarchy.hpp"
31 #include "runtime/handles.hpp"
32 #include "runtime/timer.hpp"
33 #include "services/memoryUsage.hpp"
34 
35 // A memory manager is responsible for managing one or more memory pools.
36 // The garbage collector is one type of memory managers responsible
37 // for reclaiming memory occupied by unreachable objects.  A Java virtual
38 // machine may have one or more memory managers.   It may
39 // add or remove memory managers during execution.
40 // A memory pool can be managed by more than one memory managers.
41 
42 class MemoryPool;
43 class GCMemoryManager;
44 class OopClosure;
45 
46 class MemoryManager : public CHeapObj<mtInternal> {
47 private:
48   enum {

50 
51   MemoryPool* _pools[max_num_pools];                                                                                                 
52   int         _num_pools;                                                                                                            
53 
54   const char* _name;                                                                                                                 
55 
56 protected:                                                                                                                           
57   volatile instanceOop _memory_mgr_obj;                                                                                              
58 
59 public:                                                                                                                              
60   MemoryManager(const char* name);                                                                                                   
61 
62   int num_memory_pools() const           { return _num_pools; }                                                                      
63   MemoryPool* get_memory_pool(int index) {                                                                                           
64     assert(index >= 0 && index < _num_pools, "Invalid index");                                                                       
65     return _pools[index];                                                                                                            
66   }                                                                                                                                  
67 
68   void add_pool(MemoryPool* pool);                                                                                                   
69 
70   bool is_manager(instanceHandle mh)     { return mh() == _memory_mgr_obj; }                                                         
71 
72   virtual instanceOop get_memory_manager_instance(TRAPS);                                                                            
73   virtual bool is_gc_memory_manager()    { return false; }                                                                           
74 
75   const char* name() const { return _name; }                                                                                         
76 
77   // GC support                                                                                                                      
78   void oops_do(OopClosure* f);                                                                                                       
79 
80   // Static factory methods to get a memory manager of a specific type                                                               
81   static MemoryManager*   get_code_cache_memory_manager();                                                                           
82   static MemoryManager*   get_metaspace_memory_manager();                                                                            
83 };                                                                                                                                   
84 
85 class GCStatInfo : public ResourceObj {                                                                                              
86 private:                                                                                                                             
87   size_t _index;                                                                                                                     
88   jlong  _start_time;                                                                                                                
89   jlong  _end_time;                                                                                                                  

51 
52   MemoryPool* _pools[max_num_pools];
53   int         _num_pools;
54 
55   const char* _name;
56 
57 protected:
58   volatile instanceOop _memory_mgr_obj;
59 
60 public:
61   MemoryManager(const char* name);
62 
63   int num_memory_pools() const           { return _num_pools; }
64   MemoryPool* get_memory_pool(int index) {
65     assert(index >= 0 && index < _num_pools, "Invalid index");
66     return _pools[index];
67   }
68 
69   void add_pool(MemoryPool* pool);
70 
71   bool is_manager(instanceHandle mh)     { return oopDesc::equals(mh(), _memory_mgr_obj); }
72 
73   virtual instanceOop get_memory_manager_instance(TRAPS);
74   virtual bool is_gc_memory_manager()    { return false; }
75 
76   const char* name() const { return _name; }
77 
78   // GC support
79   void oops_do(OopClosure* f);
80 
81   // Static factory methods to get a memory manager of a specific type
82   static MemoryManager*   get_code_cache_memory_manager();
83   static MemoryManager*   get_metaspace_memory_manager();
84 };
85 
86 class GCStatInfo : public ResourceObj {
87 private:
88   size_t _index;
89   jlong  _start_time;
90   jlong  _end_time;
< prev index next >