193
194 void GCMemoryManager::add_pool(MemoryPool* pool) {
195 add_pool(pool, true);
196 }
197
198 void GCMemoryManager::add_pool(MemoryPool* pool, bool always_affected_by_gc) {
199 int index = MemoryManager::add_pool(pool);
200 _pool_always_affected_by_gc[index] = always_affected_by_gc;
201 }
202
203 void GCMemoryManager::initialize_gc_stat_info() {
204 assert(MemoryService::num_memory_pools() > 0, "should have one or more memory pools");
205 _last_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
206 _current_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
207 // tracking concurrent collections we need two objects: one to update, and one to
208 // hold the publicly available "last (completed) gc" information.
209 }
210
211 void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
212 bool recordAccumulatedGCTime) {
213 assert(_last_gc_stat != NULL && _current_gc_stat != NULL, "Just checking");
214 if (recordAccumulatedGCTime) {
215 _accumulated_timer.start();
216 }
217 // _num_collections now increases in gc_end, to count completed collections
218 if (recordGCBeginTime) {
219 _current_gc_stat->set_index(_num_collections+1);
220 _current_gc_stat->set_start_time(Management::timestamp());
221 }
222
223 if (recordPreGCUsage) {
224 // Keep memory usage of all memory pools
225 for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
226 MemoryPool* pool = MemoryService::get_memory_pool(i);
227 MemoryUsage usage = pool->get_memory_usage();
228 _current_gc_stat->set_before_gc_usage(i, usage);
229 HOTSPOT_MEM_POOL_GC_BEGIN(
230 (char *) name(), strlen(name()),
231 (char *) pool->name(), strlen(pool->name()),
232 usage.init_size(), usage.used(),
233 usage.committed(), usage.max_size());
234 }
235 }
236 }
237
238 // A collector MUST, even if it does not complete for some reason,
239 // make a TraceMemoryManagerStats object where countCollection is true,
240 // to ensure the current gc stat is placed in _last_gc_stat.
241 void GCMemoryManager::gc_end(bool recordPostGCUsage,
242 bool recordAccumulatedGCTime,
243 bool recordGCEndTime, bool countCollection,
244 GCCause::Cause cause,
245 bool allMemoryPoolsAffected) {
246 if (recordAccumulatedGCTime) {
247 _accumulated_timer.stop();
248 }
249 if (recordGCEndTime) {
250 _current_gc_stat->set_end_time(Management::timestamp());
251 }
252
253 if (recordPostGCUsage) {
254 int i;
255 // keep the last gc statistics for all memory pools
256 for (i = 0; i < MemoryService::num_memory_pools(); i++) {
257 MemoryPool* pool = MemoryService::get_memory_pool(i);
258 MemoryUsage usage = pool->get_memory_usage();
259
260 HOTSPOT_MEM_POOL_GC_END(
261 (char *) name(), strlen(name()),
262 (char *) pool->name(), strlen(pool->name()),
263 usage.init_size(), usage.used(),
264 usage.committed(), usage.max_size());
265
|
193
194 void GCMemoryManager::add_pool(MemoryPool* pool) {
195 add_pool(pool, true);
196 }
197
198 void GCMemoryManager::add_pool(MemoryPool* pool, bool always_affected_by_gc) {
199 int index = MemoryManager::add_pool(pool);
200 _pool_always_affected_by_gc[index] = always_affected_by_gc;
201 }
202
203 void GCMemoryManager::initialize_gc_stat_info() {
204 assert(MemoryService::num_memory_pools() > 0, "should have one or more memory pools");
205 _last_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
206 _current_gc_stat = new(ResourceObj::C_HEAP, mtGC) GCStatInfo(MemoryService::num_memory_pools());
207 // tracking concurrent collections we need two objects: one to update, and one to
208 // hold the publicly available "last (completed) gc" information.
209 }
210
211 void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
212 bool recordAccumulatedGCTime) {
213 // Inactive memory managers (young, mixed, and concurrent in G1 legacy mode,
214 // and incremental in G1 default mode) will not be initialized.
215 if (_last_gc_stat == NULL && _current_gc_stat == NULL) return;
216
217 if (recordAccumulatedGCTime) {
218 _accumulated_timer.start();
219 }
220 // _num_collections now increases in gc_end, to count completed collections
221 if (recordGCBeginTime) {
222 _current_gc_stat->set_index(_num_collections+1);
223 _current_gc_stat->set_start_time(Management::timestamp());
224 }
225
226 if (recordPreGCUsage) {
227 // Keep memory usage of all memory pools
228 for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
229 MemoryPool* pool = MemoryService::get_memory_pool(i);
230 MemoryUsage usage = pool->get_memory_usage();
231 _current_gc_stat->set_before_gc_usage(i, usage);
232 HOTSPOT_MEM_POOL_GC_BEGIN(
233 (char *) name(), strlen(name()),
234 (char *) pool->name(), strlen(pool->name()),
235 usage.init_size(), usage.used(),
236 usage.committed(), usage.max_size());
237 }
238 }
239 }
240
241 // A collector MUST, even if it does not complete for some reason,
242 // make a TraceMemoryManagerStats object where countCollection is true,
243 // to ensure the current gc stat is placed in _last_gc_stat.
244 void GCMemoryManager::gc_end(bool recordPostGCUsage,
245 bool recordAccumulatedGCTime,
246 bool recordGCEndTime, bool countCollection,
247 GCCause::Cause cause,
248 bool allMemoryPoolsAffected) {
249 if (_last_gc_stat == NULL && _current_gc_stat == NULL) return;
250
251 if (recordAccumulatedGCTime) {
252 _accumulated_timer.stop();
253 }
254 if (recordGCEndTime) {
255 _current_gc_stat->set_end_time(Management::timestamp());
256 }
257
258 if (recordPostGCUsage) {
259 int i;
260 // keep the last gc statistics for all memory pools
261 for (i = 0; i < MemoryService::num_memory_pools(); i++) {
262 MemoryPool* pool = MemoryService::get_memory_pool(i);
263 MemoryUsage usage = pool->get_memory_usage();
264
265 HOTSPOT_MEM_POOL_GC_END(
266 (char *) name(), strlen(name()),
267 (char *) pool->name(), strlen(pool->name()),
268 usage.init_size(), usage.used(),
269 usage.committed(), usage.max_size());
270
|