@@ -45,11 +45,14 @@ void MemReporterBase::print_total(size_t reserved, size_t committed) const {
45
45
amount_in_current_scale (reserved), scale, amount_in_current_scale (committed), scale);
46
46
}
47
47
48
- void MemReporterBase::print_malloc (size_t amount, size_t count , MEMFLAGS flag) const {
48
+ void MemReporterBase::print_malloc (const MemoryCounter* c , MEMFLAGS flag) const {
49
49
const char * scale = current_scale ();
50
50
outputStream* out = output ();
51
51
const char * alloc_type = (flag == mtThreadStack) ? " " : " malloc=" ;
52
52
53
+ const size_t amount = c->size ();
54
+ const size_t count = c->count ();
55
+
53
56
if (flag != mtNone) {
54
57
out->print (" (%s" SIZE_FORMAT " %s type=%s" , alloc_type,
55
58
amount_in_current_scale (amount), scale, NMTUtil::flag_to_name (flag));
@@ -58,11 +61,21 @@ void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) c
58
61
amount_in_current_scale (amount), scale);
59
62
}
60
63
64
+ // blends out mtChunk count number
61
65
if (count > 0 ) {
62
66
out->print (" #" SIZE_FORMAT " " , count);
63
67
}
64
68
65
69
out->print (" )" );
70
+
71
+ size_t pk_amount = c->peak_size ();
72
+ if (pk_amount == amount) {
73
+ out->print_raw (" (at peak)" );
74
+ } else if (pk_amount > amount) {
75
+ size_t pk_count = c->peak_count ();
76
+ out->print (" (peak=" SIZE_FORMAT " %s #" SIZE_FORMAT " )" ,
77
+ amount_in_current_scale (pk_amount), scale, pk_count);
78
+ }
66
79
}
67
80
68
81
void MemReporterBase::print_virtual_memory (size_t reserved, size_t committed) const {
@@ -71,9 +84,9 @@ void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) co
71
84
amount_in_current_scale (reserved), scale, amount_in_current_scale (committed), scale);
72
85
}
73
86
74
- void MemReporterBase::print_malloc_line (size_t amount, size_t count ) const {
87
+ void MemReporterBase::print_malloc_line (const MemoryCounter* c ) const {
75
88
output ()->print (" %28s" , " " );
76
- print_malloc (amount, count );
89
+ print_malloc (c );
77
90
output ()->print_cr (" " );
78
91
}
79
92
@@ -83,10 +96,26 @@ void MemReporterBase::print_virtual_memory_line(size_t reserved, size_t committe
83
96
output ()->print_cr (" " );
84
97
}
85
98
86
- void MemReporterBase::print_arena_line (size_t amount, size_t count ) const {
99
+ void MemReporterBase::print_arena_line (const MemoryCounter* c ) const {
87
100
const char * scale = current_scale ();
88
- output ()->print_cr (" %27s (arena=" SIZE_FORMAT " %s #" SIZE_FORMAT " )" , " " ,
101
+ outputStream* out = output ();
102
+
103
+ const size_t amount = c->size ();
104
+ const size_t count = c->count ();
105
+
106
+ out->print (" %27s (arena=" SIZE_FORMAT " %s #" SIZE_FORMAT " )" , " " ,
89
107
amount_in_current_scale (amount), scale, count);
108
+
109
+ size_t pk_amount = c->peak_size ();
110
+ if (pk_amount == amount) {
111
+ out->print_raw (" (at peak)" );
112
+ } else if (pk_amount > amount) {
113
+ size_t pk_count = c->peak_count ();
114
+ out->print (" (peak=" SIZE_FORMAT " %s #" SIZE_FORMAT " )" ,
115
+ amount_in_current_scale (pk_amount), scale, pk_count);
116
+ }
117
+
118
+ out->cr ();
90
119
}
91
120
92
121
void MemReporterBase::print_virtual_memory_region (const char * type, address base, size_t size) const {
@@ -195,18 +224,18 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag,
195
224
}
196
225
197
226
// report malloc'd memory
198
- if (amount_in_current_scale (malloc_memory->malloc_size ()) > 0 ) {
199
- // We don't know how many arena chunks are in used, so don't report the count
200
- size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count ();
201
- print_malloc_line (malloc_memory->malloc_size (), count);
227
+ if (amount_in_current_scale (malloc_memory->malloc_size ()) > 0
228
+ DEBUG_ONLY (|| amount_in_current_scale (malloc_memory->malloc_peak_size ()) > 0 )) {
229
+ print_malloc_line (malloc_memory->malloc_counter ());
202
230
}
203
231
204
232
if (amount_in_current_scale (virtual_memory->reserved ()) > 0 ) {
205
233
print_virtual_memory_line (virtual_memory->reserved (), virtual_memory->committed ());
206
234
}
207
235
208
- if (amount_in_current_scale (malloc_memory->arena_size ()) > 0 ) {
209
- print_arena_line (malloc_memory->arena_size (), malloc_memory->arena_count ());
236
+ if (amount_in_current_scale (malloc_memory->arena_size ()) > 0
237
+ DEBUG_ONLY (|| amount_in_current_scale (malloc_memory->arena_peak_size ()) > 0 )) {
238
+ print_arena_line (malloc_memory->arena_counter ());
210
239
}
211
240
212
241
if (flag == mtNMT &&
@@ -271,12 +300,9 @@ int MemDetailReporter::report_malloc_sites() {
271
300
const MallocSite* malloc_site;
272
301
int num_omitted = 0 ;
273
302
while ((malloc_site = malloc_itr.next ()) != NULL ) {
274
- // Don't report free sites; does not count toward omitted count.
275
- if (malloc_site->size () == 0 ) {
276
- continue ;
277
- }
278
- // Don't report if site has allocated less than one unit of whatever our scale is
279
- if (scale () > 1 && amount_in_current_scale (malloc_site->size ()) == 0 ) {
303
+ // Don't report if site has never allocated less than one unit of whatever our scale is
304
+ if (scale () > 1 && amount_in_current_scale (malloc_site->size ()) == 0
305
+ DEBUG_ONLY (&& amount_in_current_scale (malloc_site->peak_size ()) == 0 )) {
280
306
num_omitted ++;
281
307
continue ;
282
308
}
@@ -286,7 +312,7 @@ int MemDetailReporter::report_malloc_sites() {
286
312
MEMFLAGS flag = malloc_site->flag ();
287
313
assert (NMTUtil::flag_is_valid (flag) && flag != mtNone,
288
314
" Must have a valid memory type" );
289
- print_malloc (malloc_site->size (), malloc_site-> count (), flag);
315
+ print_malloc (malloc_site->counter (), flag);
290
316
out->print_cr (" \n " );
291
317
}
292
318
return num_omitted;
0 commit comments