src/share/vm/services/memoryService.hpp

Thu, 05 Jun 2008 15:57:56 -0700

author
ysr
date
Thu, 05 Jun 2008 15:57:56 -0700
changeset 777
37f87013dfd8
parent 435
a61af66fc99e
child 1524
db0d5eba9d20
permissions
-rw-r--r--

6711316: Open source the Garbage-First garbage collector
Summary: First mercurial integration of the code for the Garbage-First garbage collector.
Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr

     1 /*
     2  * Copyright 2003-2006 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // Forward declaration
    26 class MemoryPool;
    27 class MemoryManager;
    28 class GCMemoryManager;
    29 class CollectedHeap;
    30 class Generation;
    31 class DefNewGeneration;
    32 class PSYoungGen;
    33 class PSOldGen;
    34 class PSPermGen;
    35 class CodeHeap;
    36 class ContiguousSpace;
    37 class CompactibleFreeListSpace;
    38 class PermanentGenerationSpec;
    39 class GenCollectedHeap;
    40 class ParallelScavengeHeap;
    41 class CompactingPermGenGen;
    42 class CMSPermGenGen;
    44 // VM Monitoring and Management Support
    46 class MemoryService : public AllStatic {
    47 private:
    48   enum {
    49     init_pools_list_size = 10,
    50     init_managers_list_size = 5
    51   };
    53   // index for minor and major generations
    54   enum {
    55     minor = 0,
    56     major = 1,
    57     n_gens = 2
    58   };
    60   static GrowableArray<MemoryPool*>*    _pools_list;
    61   static GrowableArray<MemoryManager*>* _managers_list;
    63   // memory managers for minor and major GC statistics
    64   static GCMemoryManager*               _major_gc_manager;
    65   static GCMemoryManager*               _minor_gc_manager;
    67   // Code heap memory pool
    68   static MemoryPool*                    _code_heap_pool;
    70   static void add_generation_memory_pool(Generation* gen,
    71                                          MemoryManager* major_mgr,
    72                                          MemoryManager* minor_mgr);
    73   static void add_generation_memory_pool(Generation* gen,
    74                                          MemoryManager* major_mgr) {
    75     add_generation_memory_pool(gen, major_mgr, NULL);
    76   }
    78   static void add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
    79                                                MemoryManager* mgr);
    80   static void add_cms_perm_gen_memory_pool(CMSPermGenGen* perm_gen,
    81                                            MemoryManager* mgr);
    83   static void add_psYoung_memory_pool(PSYoungGen* gen,
    84                                       MemoryManager* major_mgr,
    85                                       MemoryManager* minor_mgr);
    86   static void add_psOld_memory_pool(PSOldGen* gen,
    87                                     MemoryManager* mgr);
    88   static void add_psPerm_memory_pool(PSPermGen* perm,
    89                                      MemoryManager* mgr);
    92   static MemoryPool* add_space(ContiguousSpace* space,
    93                                const char* name,
    94                                bool is_heap,
    95                                size_t max_size,
    96                                bool support_usage_threshold);
    97   static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
    98                                          const char* name,
    99                                          bool is_heap,
   100                                          size_t max_size,
   101                                          bool support_usage_threshold);
   102   static MemoryPool* add_gen(Generation* gen,
   103                              const char* name,
   104                              bool is_heap,
   105                              bool support_usage_threshold);
   106   static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
   107                                    const char* name,
   108                                    bool is_heap,
   109                                    size_t max_size,
   110                                    bool support_usage_threshold);
   112   static void add_gen_collected_heap_info(GenCollectedHeap* heap);
   113   static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
   115 public:
   116   static void set_universe_heap(CollectedHeap* heap);
   117   static void add_code_heap_memory_pool(CodeHeap* heap);
   119   static MemoryPool*    get_memory_pool(instanceHandle pool);
   120   static MemoryManager* get_memory_manager(instanceHandle mgr);
   122   static const int num_memory_pools() {
   123     return _pools_list->length();
   124   }
   125   static const int num_memory_managers() {
   126     return _managers_list->length();
   127   }
   129   static MemoryPool* get_memory_pool(int index) {
   130     return _pools_list->at(index);
   131   }
   133   static MemoryManager* get_memory_manager(int index) {
   134     return _managers_list->at(index);
   135   }
   137   static void track_memory_usage();
   138   static void track_code_cache_memory_usage() {
   139     track_memory_pool_usage(_code_heap_pool);
   140   }
   141   static void track_memory_pool_usage(MemoryPool* pool);
   143   static void gc_begin(bool fullGC);
   144   static void gc_end(bool fullGC);
   146   static void oops_do(OopClosure* f);
   148   static bool get_verbose() { return PrintGC; }
   149   static bool set_verbose(bool verbose);
   151   // Create an instance of java/lang/management/MemoryUsage
   152   static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
   153 };
   155 class TraceMemoryManagerStats : public StackObj {
   156 private:
   157   bool         _fullGC;
   158 public:
   159   TraceMemoryManagerStats(bool fullGC);
   160   TraceMemoryManagerStats(Generation::Name kind);
   161   ~TraceMemoryManagerStats();
   162 };

mercurial