@@ -2118,22 +2118,25 @@ void os::Linux::print_process_memory_info(outputStream* st) {
2118
2118
// (note: there is no implementation of mallinfo for muslc)
2119
2119
#ifdef __GLIBC__
2120
2120
size_t total_allocated = 0 ;
2121
+ size_t free_retained = 0 ;
2121
2122
bool might_have_wrapped = false ;
2122
2123
if (_mallinfo2 != NULL ) {
2123
2124
struct glibc_mallinfo2 mi = _mallinfo2 ();
2124
- total_allocated = mi.uordblks ;
2125
+ total_allocated = mi.uordblks + mi.hblkhd ;
2126
+ free_retained = mi.fordblks ;
2125
2127
} else if (_mallinfo != NULL ) {
2126
2128
// mallinfo is an old API. Member names mean next to nothing and, beyond that, are int.
2127
2129
// So values may have wrapped around. Still useful enough to see how much glibc thinks
2128
2130
// we allocated.
2129
2131
struct glibc_mallinfo mi = _mallinfo ();
2130
- total_allocated = (size_t )(unsigned )mi.uordblks ;
2132
+ total_allocated = (size_t )(unsigned )mi.uordblks + (size_t )(unsigned )mi.hblkhd ;
2133
+ free_retained = (size_t )(unsigned )mi.fordblks ;
2131
2134
// Since mallinfo members are int, glibc values may have wrapped. Warn about this.
2132
2135
might_have_wrapped = (info.vmrss * K) > UINT_MAX && (info.vmrss * K) > (total_allocated + UINT_MAX);
2133
2136
}
2134
2137
if (_mallinfo2 != NULL || _mallinfo != NULL ) {
2135
- st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K%s" ,
2136
- total_allocated / K,
2138
+ st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K, retained: " SIZE_FORMAT " K %s" ,
2139
+ total_allocated / K, free_retained / K,
2137
2140
might_have_wrapped ? " (may have wrapped)" : " " );
2138
2141
}
2139
2142
#endif // __GLIBC__
0 commit comments