< prev index next >

src/hotspot/share/services/memoryService.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. 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 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  *


 163 }
 164 
 165 void MemoryService::gc_begin(GCMemoryManager* manager, bool recordGCBeginTime,
 166                              bool recordAccumulatedGCTime,
 167                              bool recordPreGCUsage, bool recordPeakUsage) {
 168 
 169   manager->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
 170 
 171   // Track the peak memory usage when GC begins
 172   if (recordPeakUsage) {
 173     for (int i = 0; i < _pools_list->length(); i++) {
 174       MemoryPool* pool = _pools_list->at(i);
 175       pool->record_peak_memory_usage();
 176     }
 177   }
 178 }
 179 
 180 void MemoryService::gc_end(GCMemoryManager* manager, bool recordPostGCUsage,
 181                            bool recordAccumulatedGCTime,
 182                            bool recordGCEndTime, bool countCollection,
 183                            GCCause::Cause cause) {

 184   // register the GC end statistics and memory usage
 185   manager->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
 186                   countCollection, cause);
 187 }
 188 
 189 void MemoryService::oops_do(OopClosure* f) {
 190   int i;
 191 
 192   for (i = 0; i < _pools_list->length(); i++) {
 193     MemoryPool* pool = _pools_list->at(i);
 194     pool->oops_do(f);
 195   }
 196   for (i = 0; i < _managers_list->length(); i++) {
 197     MemoryManager* mgr = _managers_list->at(i);
 198     mgr->oops_do(f);
 199   }
 200 }
 201 
 202 bool MemoryService::set_verbose(bool verbose) {
 203   MutexLocker m(Management_lock);
 204   // verbose will be set to the previous value
 205   if (verbose) {
 206     LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));


 219 
 220   JavaValue result(T_VOID);
 221   JavaCallArguments args(10);
 222   args.push_oop(obj);                         // receiver
 223   args.push_long(usage.init_size_as_jlong()); // Argument 1
 224   args.push_long(usage.used_as_jlong());      // Argument 2
 225   args.push_long(usage.committed_as_jlong()); // Argument 3
 226   args.push_long(usage.max_size_as_jlong());  // Argument 4
 227 
 228   JavaCalls::call_special(&result,
 229                           ik,
 230                           vmSymbols::object_initializer_name(),
 231                           vmSymbols::long_long_long_long_void_signature(),
 232                           &args,
 233                           CHECK_NH);
 234   return obj;
 235 }
 236 
 237 TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager,
 238                                                  GCCause::Cause cause,

 239                                                  bool recordGCBeginTime,
 240                                                  bool recordPreGCUsage,
 241                                                  bool recordPeakUsage,
 242                                                  bool recordPostGCUsage,
 243                                                  bool recordAccumulatedGCTime,
 244                                                  bool recordGCEndTime,
 245                                                  bool countCollection) {
 246   initialize(gc_memory_manager, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
 247              recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
 248              countCollection);
 249 }
 250 
 251 // for a subclass to create then initialize an instance before invoking
 252 // the MemoryService
 253 void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_memory_manager,
 254                                          GCCause::Cause cause,
 255                                          bool recordGCBeginTime,
 256                                          bool recordPreGCUsage,
 257                                          bool recordPeakUsage,
 258                                          bool recordPostGCUsage,
 259                                          bool recordAccumulatedGCTime,
 260                                          bool recordGCEndTime,
 261                                          bool countCollection) {

 262   _gc_memory_manager = gc_memory_manager;

 263   _recordGCBeginTime = recordGCBeginTime;
 264   _recordPreGCUsage = recordPreGCUsage;
 265   _recordPeakUsage = recordPeakUsage;
 266   _recordPostGCUsage = recordPostGCUsage;
 267   _recordAccumulatedGCTime = recordAccumulatedGCTime;
 268   _recordGCEndTime = recordGCEndTime;
 269   _countCollection = countCollection;
 270   _cause = cause;
 271 
 272   MemoryService::gc_begin(_gc_memory_manager, _recordGCBeginTime, _recordAccumulatedGCTime,
 273                           _recordPreGCUsage, _recordPeakUsage);
 274 }
 275 
 276 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
 277   MemoryService::gc_end(_gc_memory_manager, _recordPostGCUsage, _recordAccumulatedGCTime,
 278                         _recordGCEndTime, _countCollection, _cause);
 279 }
   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. 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 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  *


 163 }
 164 
 165 void MemoryService::gc_begin(GCMemoryManager* manager, bool recordGCBeginTime,
 166                              bool recordAccumulatedGCTime,
 167                              bool recordPreGCUsage, bool recordPeakUsage) {
 168 
 169   manager->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
 170 
 171   // Track the peak memory usage when GC begins
 172   if (recordPeakUsage) {
 173     for (int i = 0; i < _pools_list->length(); i++) {
 174       MemoryPool* pool = _pools_list->at(i);
 175       pool->record_peak_memory_usage();
 176     }
 177   }
 178 }
 179 
 180 void MemoryService::gc_end(GCMemoryManager* manager, bool recordPostGCUsage,
 181                            bool recordAccumulatedGCTime,
 182                            bool recordGCEndTime, bool countCollection,
 183                            GCCause::Cause cause,
 184                            bool allMemoryPoolsAffected) {
 185   // register the GC end statistics and memory usage
 186   manager->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
 187                   countCollection, cause, allMemoryPoolsAffected);
 188 }
 189 
 190 void MemoryService::oops_do(OopClosure* f) {
 191   int i;
 192 
 193   for (i = 0; i < _pools_list->length(); i++) {
 194     MemoryPool* pool = _pools_list->at(i);
 195     pool->oops_do(f);
 196   }
 197   for (i = 0; i < _managers_list->length(); i++) {
 198     MemoryManager* mgr = _managers_list->at(i);
 199     mgr->oops_do(f);
 200   }
 201 }
 202 
 203 bool MemoryService::set_verbose(bool verbose) {
 204   MutexLocker m(Management_lock);
 205   // verbose will be set to the previous value
 206   if (verbose) {
 207     LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));


 220 
 221   JavaValue result(T_VOID);
 222   JavaCallArguments args(10);
 223   args.push_oop(obj);                         // receiver
 224   args.push_long(usage.init_size_as_jlong()); // Argument 1
 225   args.push_long(usage.used_as_jlong());      // Argument 2
 226   args.push_long(usage.committed_as_jlong()); // Argument 3
 227   args.push_long(usage.max_size_as_jlong());  // Argument 4
 228 
 229   JavaCalls::call_special(&result,
 230                           ik,
 231                           vmSymbols::object_initializer_name(),
 232                           vmSymbols::long_long_long_long_void_signature(),
 233                           &args,
 234                           CHECK_NH);
 235   return obj;
 236 }
 237 
 238 TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager,
 239                                                  GCCause::Cause cause,
 240                                                  bool allMemoryPoolsAffected,
 241                                                  bool recordGCBeginTime,
 242                                                  bool recordPreGCUsage,
 243                                                  bool recordPeakUsage,
 244                                                  bool recordPostGCUsage,
 245                                                  bool recordAccumulatedGCTime,
 246                                                  bool recordGCEndTime,
 247                                                  bool countCollection) {
 248   initialize(gc_memory_manager, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
 249              recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
 250              countCollection, allMemoryPoolsAffected);
 251 }
 252 
 253 // for a subclass to create then initialize an instance before invoking
 254 // the MemoryService
 255 void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_memory_manager,
 256                                          GCCause::Cause cause,
 257                                          bool recordGCBeginTime,
 258                                          bool recordPreGCUsage,
 259                                          bool recordPeakUsage,
 260                                          bool recordPostGCUsage,
 261                                          bool recordAccumulatedGCTime,
 262                                          bool recordGCEndTime,
 263                                          bool countCollection,
 264                                          bool allMemoryPoolsAffected) {
 265   _gc_memory_manager = gc_memory_manager;
 266   _allMemoryPoolsAffected = allMemoryPoolsAffected;
 267   _recordGCBeginTime = recordGCBeginTime;
 268   _recordPreGCUsage = recordPreGCUsage;
 269   _recordPeakUsage = recordPeakUsage;
 270   _recordPostGCUsage = recordPostGCUsage;
 271   _recordAccumulatedGCTime = recordAccumulatedGCTime;
 272   _recordGCEndTime = recordGCEndTime;
 273   _countCollection = countCollection;
 274   _cause = cause;
 275 
 276   MemoryService::gc_begin(_gc_memory_manager, _recordGCBeginTime, _recordAccumulatedGCTime,
 277                           _recordPreGCUsage, _recordPeakUsage);
 278 }
 279 
 280 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
 281   MemoryService::gc_end(_gc_memory_manager, _recordPostGCUsage, _recordAccumulatedGCTime,
 282                         _recordGCEndTime, _countCollection, _cause, _allMemoryPoolsAffected);
 283 }
< prev index next >