@@ -2404,23 +2404,26 @@ void os::Linux::print_process_memory_info(outputStream* st) {
2404
2404
// - Print glibc tunables
2405
2405
#ifdef __GLIBC__
2406
2406
size_t total_allocated = 0 ;
2407
+ size_t free_retained = 0 ;
2407
2408
bool might_have_wrapped = false ;
2408
2409
if (_mallinfo2 != NULL ) {
2409
2410
struct glibc_mallinfo2 mi = _mallinfo2 ();
2410
- total_allocated = mi.uordblks ;
2411
+ total_allocated = mi.uordblks + mi.hblkhd ;
2412
+ free_retained = mi.fordblks ;
2411
2413
} else if (_mallinfo != NULL ) {
2412
2414
// mallinfo is an old API. Member names mean next to nothing and, beyond that, are 32-bit signed.
2413
2415
// So for larger footprints the values may have wrapped around. We try to detect this here: if the
2414
2416
// process whole resident set size is smaller than 4G, malloc footprint has to be less than that
2415
2417
// and the numbers are reliable.
2416
2418
struct glibc_mallinfo mi = _mallinfo ();
2417
- total_allocated = (size_t )(unsigned )mi.uordblks ;
2419
+ total_allocated = (size_t )(unsigned )mi.uordblks + (size_t )(unsigned )mi.hblkhd ;
2420
+ free_retained = (size_t )(unsigned )mi.fordblks ;
2418
2421
// Since mallinfo members are int, glibc values may have wrapped. Warn about this.
2419
2422
might_have_wrapped = (vmrss * K) > UINT_MAX && (vmrss * K) > (total_allocated + UINT_MAX);
2420
2423
}
2421
2424
if (_mallinfo2 != NULL || _mallinfo != NULL ) {
2422
- st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K%s" ,
2423
- total_allocated / K,
2425
+ st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K, retained: " SIZE_FORMAT " K %s" ,
2426
+ total_allocated / K, free_retained / K,
2424
2427
might_have_wrapped ? " (may have wrapped)" : " " );
2425
2428
}
2426
2429
// Tunables
0 commit comments