@@ -2152,23 +2152,26 @@ void os::Linux::print_process_memory_info(outputStream* st) {
2152
2152
// - Print glibc tunables
2153
2153
#ifdef __GLIBC__
2154
2154
size_t total_allocated = 0 ;
2155
+ size_t free_retained = 0 ;
2155
2156
bool might_have_wrapped = false ;
2156
2157
if (_mallinfo2 != NULL ) {
2157
2158
struct glibc_mallinfo2 mi = _mallinfo2 ();
2158
- total_allocated = mi.uordblks ;
2159
+ total_allocated = mi.uordblks + mi.hblkhd ;
2160
+ free_retained = mi.fordblks ;
2159
2161
} else if (_mallinfo != NULL ) {
2160
2162
// mallinfo is an old API. Member names mean next to nothing and, beyond that, are 32-bit signed.
2161
2163
// So for larger footprints the values may have wrapped around. We try to detect this here: if the
2162
2164
// process whole resident set size is smaller than 4G, malloc footprint has to be less than that
2163
2165
// and the numbers are reliable.
2164
2166
struct glibc_mallinfo mi = _mallinfo ();
2165
- total_allocated = (size_t )(unsigned )mi.uordblks ;
2167
+ total_allocated = (size_t )(unsigned )mi.uordblks + (size_t )(unsigned )mi.hblkhd ;
2168
+ free_retained = (size_t )(unsigned )mi.fordblks ;
2166
2169
// Since mallinfo members are int, glibc values may have wrapped. Warn about this.
2167
2170
might_have_wrapped = (info.vmrss * K) > UINT_MAX && (info.vmrss * K) > (total_allocated + UINT_MAX);
2168
2171
}
2169
2172
if (_mallinfo2 != NULL || _mallinfo != NULL ) {
2170
- st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K%s" ,
2171
- total_allocated / K,
2173
+ st->print_cr (" C-Heap outstanding allocations: " SIZE_FORMAT " K, retained: " SIZE_FORMAT " K %s" ,
2174
+ total_allocated / K, free_retained / K,
2172
2175
might_have_wrapped ? " (may have wrapped)" : " " );
2173
2176
}
2174
2177
// Tunables
0 commit comments