< prev index next >

src/hotspot/share/services/memoryPool.cpp

Print this page
rev 48000 : [mq]: open.patch


   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 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "gc/serial/defNewGeneration.hpp"
  29 #include "gc/shared/space.hpp"
  30 #include "memory/metaspace.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/javaCalls.hpp"
  34 #include "runtime/orderAccess.inline.hpp"
  35 #include "services/lowMemoryDetector.hpp"
  36 #include "services/management.hpp"
  37 #include "services/memoryManager.hpp"
  38 #include "services/memoryPool.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 #include "utilities/macros.hpp"
  41 #if INCLUDE_ALL_GCS
  42 #include "gc/cms/compactibleFreeListSpace.hpp"
  43 #endif
  44 
  45 MemoryPool::MemoryPool(const char* name,
  46                        PoolType type,
  47                        size_t init_size,
  48                        size_t max_size,
  49                        bool support_usage_threshold,
  50                        bool support_gc_threshold) {
  51   _name = name;
  52   _initial_size = init_size;
  53   _max_size = max_size;
  54   (void)const_cast<instanceOop&>(_memory_pool_obj = instanceOop(NULL));
  55   _available_for_allocation = true;
  56   _num_managers = 0;
  57   _type = type;
  58 
  59   // initialize the max and init size of collection usage
  60   _after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
  61 
  62   _usage_sensor = NULL;
  63   _gc_usage_sensor = NULL;


 163   sensor->set_sensor(sh());
 164   *sensor_ptr = sensor;
 165 }
 166 
 167 void MemoryPool::set_usage_sensor_obj(instanceHandle sh) {
 168   set_sensor_obj_at(&_usage_sensor, sh);
 169 }
 170 
 171 void MemoryPool::set_gc_usage_sensor_obj(instanceHandle sh) {
 172   set_sensor_obj_at(&_gc_usage_sensor, sh);
 173 }
 174 
 175 void MemoryPool::oops_do(OopClosure* f) {
 176   f->do_oop((oop*) &_memory_pool_obj);
 177   if (_usage_sensor != NULL) {
 178     _usage_sensor->oops_do(f);
 179   }
 180   if (_gc_usage_sensor != NULL) {
 181     _gc_usage_sensor->oops_do(f);
 182   }
 183 }
 184 
 185 ContiguousSpacePool::ContiguousSpacePool(ContiguousSpace* space,
 186                                          const char* name,
 187                                          PoolType type,
 188                                          size_t max_size,
 189                                          bool support_usage_threshold) :
 190   CollectedMemoryPool(name, type, space->capacity(), max_size,
 191                       support_usage_threshold), _space(space) {
 192 }
 193 
 194 size_t ContiguousSpacePool::used_in_bytes() {
 195   return space()->used();
 196 }
 197 
 198 MemoryUsage ContiguousSpacePool::get_memory_usage() {
 199   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 200   size_t used      = used_in_bytes();
 201   size_t committed = _space->capacity();
 202 
 203   return MemoryUsage(initial_size(), used, committed, maxSize);
 204 }
 205 
 206 SurvivorContiguousSpacePool::SurvivorContiguousSpacePool(DefNewGeneration* young_gen,
 207                                                          const char* name,
 208                                                          PoolType type,
 209                                                          size_t max_size,
 210                                                          bool support_usage_threshold) :
 211   CollectedMemoryPool(name, type, young_gen->from()->capacity(), max_size,
 212                       support_usage_threshold), _young_gen(young_gen) {
 213 }
 214 
 215 size_t SurvivorContiguousSpacePool::used_in_bytes() {
 216   return _young_gen->from()->used();
 217 }
 218 
 219 size_t SurvivorContiguousSpacePool::committed_in_bytes() {
 220   return _young_gen->from()->capacity();
 221 }
 222 
 223 MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
 224   size_t maxSize = (available_for_allocation() ? max_size() : 0);
 225   size_t used    = used_in_bytes();
 226   size_t committed = committed_in_bytes();
 227 
 228   return MemoryUsage(initial_size(), used, committed, maxSize);
 229 }
 230 
 231 #if INCLUDE_ALL_GCS
 232 CompactibleFreeListSpacePool::CompactibleFreeListSpacePool(CompactibleFreeListSpace* space,
 233                                                            const char* name,
 234                                                            PoolType type,
 235                                                            size_t max_size,
 236                                                            bool support_usage_threshold) :
 237   CollectedMemoryPool(name, type, space->capacity(), max_size,
 238                       support_usage_threshold), _space(space) {
 239 }
 240 
 241 size_t CompactibleFreeListSpacePool::used_in_bytes() {
 242   return _space->used();
 243 }
 244 
 245 MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() {
 246   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 247   size_t used      = used_in_bytes();
 248   size_t committed = _space->capacity();
 249 
 250   return MemoryUsage(initial_size(), used, committed, maxSize);
 251 }
 252 #endif // INCLUDE_ALL_GCS
 253 
 254 GenerationPool::GenerationPool(Generation* gen,
 255                                const char* name,
 256                                PoolType type,
 257                                bool support_usage_threshold) :
 258   CollectedMemoryPool(name, type, gen->capacity(), gen->max_capacity(),
 259                       support_usage_threshold), _gen(gen) {
 260 }
 261 
 262 size_t GenerationPool::used_in_bytes() {
 263   return _gen->used();
 264 }
 265 
 266 MemoryUsage GenerationPool::get_memory_usage() {
 267   size_t used      = used_in_bytes();
 268   size_t committed = _gen->capacity();
 269   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 270 
 271   return MemoryUsage(initial_size(), used, committed, maxSize);
 272 }
 273 
 274 CodeHeapPool::CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_usage_threshold) :
 275   MemoryPool(name, NonHeap, codeHeap->capacity(), codeHeap->max_capacity(),
 276              support_usage_threshold, false), _codeHeap(codeHeap) {
 277 }
 278 
 279 MemoryUsage CodeHeapPool::get_memory_usage() {
 280   size_t used      = used_in_bytes();
 281   size_t committed = _codeHeap->capacity();
 282   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 283 
 284   return MemoryUsage(initial_size(), used, committed, maxSize);
 285 }
 286 
 287 MetaspacePool::MetaspacePool() :
 288   MemoryPool("Metaspace", NonHeap, 0, calculate_max_size(), true, false) { }
 289 
 290 MemoryUsage MetaspacePool::get_memory_usage() {
 291   size_t committed = MetaspaceAux::committed_bytes();




   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 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"


  28 #include "memory/metaspace.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/javaCalls.hpp"
  32 #include "runtime/orderAccess.inline.hpp"
  33 #include "services/lowMemoryDetector.hpp"
  34 #include "services/management.hpp"
  35 #include "services/memoryManager.hpp"
  36 #include "services/memoryPool.hpp"
  37 #include "utilities/globalDefinitions.hpp"
  38 #include "utilities/macros.hpp"



  39 
  40 MemoryPool::MemoryPool(const char* name,
  41                        PoolType type,
  42                        size_t init_size,
  43                        size_t max_size,
  44                        bool support_usage_threshold,
  45                        bool support_gc_threshold) {
  46   _name = name;
  47   _initial_size = init_size;
  48   _max_size = max_size;
  49   (void)const_cast<instanceOop&>(_memory_pool_obj = instanceOop(NULL));
  50   _available_for_allocation = true;
  51   _num_managers = 0;
  52   _type = type;
  53 
  54   // initialize the max and init size of collection usage
  55   _after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
  56 
  57   _usage_sensor = NULL;
  58   _gc_usage_sensor = NULL;


 158   sensor->set_sensor(sh());
 159   *sensor_ptr = sensor;
 160 }
 161 
 162 void MemoryPool::set_usage_sensor_obj(instanceHandle sh) {
 163   set_sensor_obj_at(&_usage_sensor, sh);
 164 }
 165 
 166 void MemoryPool::set_gc_usage_sensor_obj(instanceHandle sh) {
 167   set_sensor_obj_at(&_gc_usage_sensor, sh);
 168 }
 169 
 170 void MemoryPool::oops_do(OopClosure* f) {
 171   f->do_oop((oop*) &_memory_pool_obj);
 172   if (_usage_sensor != NULL) {
 173     _usage_sensor->oops_do(f);
 174   }
 175   if (_gc_usage_sensor != NULL) {
 176     _gc_usage_sensor->oops_do(f);
 177   }

























































































 178 }
 179 
 180 CodeHeapPool::CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_usage_threshold) :
 181   MemoryPool(name, NonHeap, codeHeap->capacity(), codeHeap->max_capacity(),
 182              support_usage_threshold, false), _codeHeap(codeHeap) {
 183 }
 184 
 185 MemoryUsage CodeHeapPool::get_memory_usage() {
 186   size_t used      = used_in_bytes();
 187   size_t committed = _codeHeap->capacity();
 188   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
 189 
 190   return MemoryUsage(initial_size(), used, committed, maxSize);
 191 }
 192 
 193 MetaspacePool::MetaspacePool() :
 194   MemoryPool("Metaspace", NonHeap, 0, calculate_max_size(), true, false) { }
 195 
 196 MemoryUsage MetaspacePool::get_memory_usage() {
 197   size_t committed = MetaspaceAux::committed_bytes();


< prev index next >