@@ -2232,23 +2232,26 @@ void os::Linux::print_process_memory_info(outputStream* st) {
2232
2232
// - Print glibc tunables
2233
2233
#ifdef __GLIBC__
2234
2234
size_t total_allocated = 0 ;
2235
+ size_t free_retained = 0 ;
2235
2236
bool might_have_wrapped = false ;
2236
2237
if (_mallinfo2 != NULL ) {
2237
2238
struct glibc_mallinfo2 mi = _mallinfo2 ();
2238
- total_allocated = mi.uordblks ;
2239
+ total_allocated = mi.uordblks + mi.hblkhd ;
2240
+ free_retained = mi.fordblks ;
2239
2241
} else if (_mallinfo != NULL ) {
2240
2242
// mallinfo is an old API. Member names mean next to nothing and, beyond that, are 32-bit signed.
2241
2243
// So for larger footprints the values may have wrapped around. We try to detect this here: if the
2242
2244
// process whole resident set size is smaller than 4G, malloc footprint has to be less than that
2243
2245
// and the numbers are reliable.
2244
2246
struct glibc_mallinfo mi = _mallinfo ();
2245
- total_allocated = (size_t )(unsigned )mi.uordblks ;
2247
+ total_allocated = (size_t )(unsigned )mi.uordblks + (size_t )(unsigned )mi.hblkhd ;
2248
+ free_retained = (size_t )(unsigned )mi.fordblks ;
2246
2249
// Since mallinfo members are int, glibc values may have wrapped. Warn about this.
2247
2250
might_have_wrapped = (info.vmrss * K) > UINT_MAX && (info.vmrss * K) > (total_allocated + UINT_MAX);
2248
2251
}
2249
2252
if (_mallinfo2 != NULL || _mallinfo != NULL ) {
2250
- st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K%s" ,
2251
- total_allocated / K,
2253
+ st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K, retained: " SIZE_FORMAT " K %s" ,
2254
+ total_allocated / K, free_retained / K,
2252
2255
might_have_wrapped ? " (may have wrapped)" : " " );
2253
2256
}
2254
2257
// Tunables
0 commit comments