JDK-8303767 : Identify and address the likely causes of glibc allocator fragmentation
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,17,21
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2023-03-07
  • Updated: 2025-11-25
  • Resolved: 2025-11-25
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
glibc can sometimes, especially in case of multi threaded applications, keep certain pages in physical memory even though those pages have already been freed. This can be observed as increase in RSS for programs using glibc allocator.

The goal of this issue is to identify if there are any allocation patterns in the JVM that can lead to such memory fragmentation and in turn cause increase in RSS for Java applications.
Comments
There is not much more to do with this ticket. The issues with the default glibc allocator are not something that we can change, they are inherent to the allocator itself.
25-11-2025

Unfortunately, removing the arena chunk pool increased fragmentation. Addressing the causes of the glibc allocator fragmentation is quite difficult to do on the JVM side as it is a concern of the glibc implementation. The best solution that we have for this is a work around via HeapTrim, as mentioned previously.
14-04-2025

We are currently investigating the removal of the Arena ChunkPool. This will likely reduce glibc malloc fragmentation. If a user wants to minimize fragmentation for themselves, then they could either use the HeapTrim functionality on Linux, or they could LD_PRELOAD a different allocator such as Mesh: https://github.com/plasma-umass/Mesh
19-11-2024

Starting a JFR recording with OldObjectSample event enabled will trigger this problem in a very visible way for application starting many threads (in my case the 'akka-uct' from Renaissance benchmark).
14-04-2024

The best mitigation that we have today is the native heap trim functionality that Thomas Stüfe exposed.
06-02-2024

Another possible mitigation might be using a smaller MALLOC_ARENA_MAX (see JDK-8193521).
06-02-2024

Thanks Vladimir! I missed that.
10-03-2023

I assume this is general bug to find all causes of fragmentation and RSS memory increase. Dynamic creation/termination of compiler threads improvement will be addressed by separate RFE JDK-8302264.
09-03-2023

Dynamic creation/termination of compiler threads (added with JDK-8198756) seems to increase the likelihood of fragmentation.
09-03-2023

Tentative ILW = Memory fragmentation leading to increase in RSS, with certain VM allocation patterns, no workaround but disabling of some VM features might mitigate the issue = MMM = P3
09-03-2023