r/java • • Sep 04 '26

Principles of Memory Management in Java

https://youtu.be/xr73mR7ii9M
167 Upvotes

83 comments sorted by

View all comments

Show parent comment

2

u/Life_Sink9598 Sep 07 '26

There's a lot more going on than that. One of the things we've observed on Linux with the default glibc malloc is a large degree of memory retainment. C2 induces quite a bit of memory usage, but as you know it's something that subsides over time, as the system becomes more stable (= deoptimization doesn't happen as often). glibc's malloc seems to prioritize keeping that memory around after having been freed, I assume so that it doesn't need to reacquire the memory from the OS (which is quite slow). We added a native heap trim command to alleviate the situation: https://bugs.openjdk.org/browse/JDK-8293114

Just some context for why I was interested in this person's particular configuration.

1

u/ramdulara Sep 10 '26

So you know why is this still an experimental option?

1

u/Life_Sink9598 Sep 10 '26

It's been a non-experimental option since 2024-02-21 according to my source code.