src/share/vm/services/memoryService.hpp

changeset 435
a61af66fc99e
child 1524
db0d5eba9d20
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/services/memoryService.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,162 @@
     1.4 +/*
     1.5 + * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// Forward declaration
    1.29 +class MemoryPool;
    1.30 +class MemoryManager;
    1.31 +class GCMemoryManager;
    1.32 +class CollectedHeap;
    1.33 +class Generation;
    1.34 +class DefNewGeneration;
    1.35 +class PSYoungGen;
    1.36 +class PSOldGen;
    1.37 +class PSPermGen;
    1.38 +class CodeHeap;
    1.39 +class ContiguousSpace;
    1.40 +class CompactibleFreeListSpace;
    1.41 +class PermanentGenerationSpec;
    1.42 +class GenCollectedHeap;
    1.43 +class ParallelScavengeHeap;
    1.44 +class CompactingPermGenGen;
    1.45 +class CMSPermGenGen;
    1.46 +
    1.47 +// VM Monitoring and Management Support
    1.48 +
    1.49 +class MemoryService : public AllStatic {
    1.50 +private:
    1.51 +  enum {
    1.52 +    init_pools_list_size = 10,
    1.53 +    init_managers_list_size = 5
    1.54 +  };
    1.55 +
    1.56 +  // index for minor and major generations
    1.57 +  enum {
    1.58 +    minor = 0,
    1.59 +    major = 1,
    1.60 +    n_gens = 2
    1.61 +  };
    1.62 +
    1.63 +  static GrowableArray<MemoryPool*>*    _pools_list;
    1.64 +  static GrowableArray<MemoryManager*>* _managers_list;
    1.65 +
    1.66 +  // memory managers for minor and major GC statistics
    1.67 +  static GCMemoryManager*               _major_gc_manager;
    1.68 +  static GCMemoryManager*               _minor_gc_manager;
    1.69 +
    1.70 +  // Code heap memory pool
    1.71 +  static MemoryPool*                    _code_heap_pool;
    1.72 +
    1.73 +  static void add_generation_memory_pool(Generation* gen,
    1.74 +                                         MemoryManager* major_mgr,
    1.75 +                                         MemoryManager* minor_mgr);
    1.76 +  static void add_generation_memory_pool(Generation* gen,
    1.77 +                                         MemoryManager* major_mgr) {
    1.78 +    add_generation_memory_pool(gen, major_mgr, NULL);
    1.79 +  }
    1.80 +
    1.81 +  static void add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
    1.82 +                                               MemoryManager* mgr);
    1.83 +  static void add_cms_perm_gen_memory_pool(CMSPermGenGen* perm_gen,
    1.84 +                                           MemoryManager* mgr);
    1.85 +
    1.86 +  static void add_psYoung_memory_pool(PSYoungGen* gen,
    1.87 +                                      MemoryManager* major_mgr,
    1.88 +                                      MemoryManager* minor_mgr);
    1.89 +  static void add_psOld_memory_pool(PSOldGen* gen,
    1.90 +                                    MemoryManager* mgr);
    1.91 +  static void add_psPerm_memory_pool(PSPermGen* perm,
    1.92 +                                     MemoryManager* mgr);
    1.93 +
    1.94 +
    1.95 +  static MemoryPool* add_space(ContiguousSpace* space,
    1.96 +                               const char* name,
    1.97 +                               bool is_heap,
    1.98 +                               size_t max_size,
    1.99 +                               bool support_usage_threshold);
   1.100 +  static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
   1.101 +                                         const char* name,
   1.102 +                                         bool is_heap,
   1.103 +                                         size_t max_size,
   1.104 +                                         bool support_usage_threshold);
   1.105 +  static MemoryPool* add_gen(Generation* gen,
   1.106 +                             const char* name,
   1.107 +                             bool is_heap,
   1.108 +                             bool support_usage_threshold);
   1.109 +  static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
   1.110 +                                   const char* name,
   1.111 +                                   bool is_heap,
   1.112 +                                   size_t max_size,
   1.113 +                                   bool support_usage_threshold);
   1.114 +
   1.115 +  static void add_gen_collected_heap_info(GenCollectedHeap* heap);
   1.116 +  static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
   1.117 +
   1.118 +public:
   1.119 +  static void set_universe_heap(CollectedHeap* heap);
   1.120 +  static void add_code_heap_memory_pool(CodeHeap* heap);
   1.121 +
   1.122 +  static MemoryPool*    get_memory_pool(instanceHandle pool);
   1.123 +  static MemoryManager* get_memory_manager(instanceHandle mgr);
   1.124 +
   1.125 +  static const int num_memory_pools() {
   1.126 +    return _pools_list->length();
   1.127 +  }
   1.128 +  static const int num_memory_managers() {
   1.129 +    return _managers_list->length();
   1.130 +  }
   1.131 +
   1.132 +  static MemoryPool* get_memory_pool(int index) {
   1.133 +    return _pools_list->at(index);
   1.134 +  }
   1.135 +
   1.136 +  static MemoryManager* get_memory_manager(int index) {
   1.137 +    return _managers_list->at(index);
   1.138 +  }
   1.139 +
   1.140 +  static void track_memory_usage();
   1.141 +  static void track_code_cache_memory_usage() {
   1.142 +    track_memory_pool_usage(_code_heap_pool);
   1.143 +  }
   1.144 +  static void track_memory_pool_usage(MemoryPool* pool);
   1.145 +
   1.146 +  static void gc_begin(bool fullGC);
   1.147 +  static void gc_end(bool fullGC);
   1.148 +
   1.149 +  static void oops_do(OopClosure* f);
   1.150 +
   1.151 +  static bool get_verbose() { return PrintGC; }
   1.152 +  static bool set_verbose(bool verbose);
   1.153 +
   1.154 +  // Create an instance of java/lang/management/MemoryUsage
   1.155 +  static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
   1.156 +};
   1.157 +
   1.158 +class TraceMemoryManagerStats : public StackObj {
   1.159 +private:
   1.160 +  bool         _fullGC;
   1.161 +public:
   1.162 +  TraceMemoryManagerStats(bool fullGC);
   1.163 +  TraceMemoryManagerStats(Generation::Name kind);
   1.164 +  ~TraceMemoryManagerStats();
   1.165 +};

mercurial