-
Enhancement
-
Resolution: Fixed
-
P4
-
17, 21, 22
-
b08
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8314107 | 21.0.1 | Aleksey Shipilev | P4 | Resolved | Fixed | b08 |
JDK-8315028 | 17.0.9 | Aleksey Shipilev | P4 | Resolved | Fixed | b05 |
The Glibc allocator is reluctant to return memory to the OS, much more so than other allocators. Temporary malloc spikes often carry over as permanent RSS increase.
Note that C-heap retention is difficult to observe. Since it is freed memory, it won't show up in NMT, it is just a part of private RSS.
Theoretically, retained memory is not lost since it will be reused by future mallocs. Retaining memory is therefore a bet on the future behavior of the app. The allocator bets on the application needing memory in the near future, and to satisfy that need via malloc.
But an app's malloc load can fluctuate wildly, with temporary spikes and long idle periods. And if the app rolls its own custom allocators atop of mmap, as hotspot does, a lot of that memory cannot be reused even though it counts toward its memory footprint.
To help, Glibc exports an API to trim the C-heap: malloc_trim(3). It would be good if we were to integrate it into the JVM as an optional GC step.
[1] https://mail.openjdk.org/pipermail/hotspot-dev/2021-August/054323.html
- backported by
-
JDK-8314107 JVM should trim the native heap
- Resolved
-
JDK-8315028 JVM should trim the native heap
- Resolved
- relates to
-
JDK-8312525 New test runtime/os/TestTrimNative.java#trimNative is failing: did not see the expected RSS reduction
- Resolved
-
JDK-8314426 runtime/os/TestTrimNative.java is failing on slow machines
- Resolved
-
JDK-8296784 Provide clean mallinfo/mallinfo2 wrapper for Linux glibc platforms
- Resolved
-
JDK-8296796 Provide clean, platform-agnostic interface to C-heap trimming
- Resolved
-
JDK-8325496 Make TrimNativeHeapInterval a product switch
- Resolved
-
JDK-8268893 jcmd to trim the glibc heap
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/f667b356
-
Commit openjdk/jdk21u/a094e937
-
Commit openjdk/jdk/9e4fc568
-
Review openjdk/jdk17u-dev/1616
-
Review openjdk/jdk21u/13
-
Review openjdk/jdk/10085
-
Review openjdk/jdk/14781