Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hotspot/os/linux/globals_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
"omitted.\n" \
"Example: \"-XX:HiMemReportExec=GC.class_histogram -all;GC.heap_dump\"") \
\
/* SapMachine 2025-11-24: Configurable limit of malloc arenas */ \
product(int, GlibcMallocArenas, 0, \
"Limit glibc malloc arenas, 0 means use OS default, " \
"1 minimizes memory utilization (our default in later releases)") \
\
product(bool, UseCpuAllocPath, false, DIAGNOSTIC, \
"Use CPU_ALLOC code path in os::active_processor_count ") \
\
Expand Down
15 changes: 15 additions & 0 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4792,6 +4792,21 @@ jint os::init_2(void) {

Linux::fast_thread_clock_init();

// SapMachine 2025-11-24:
// By default, glibc allocates a new 64 (or 128) MB malloc arena for every
// thread (up to a certain limit which is typically 8 * processor count).
// This is good for few threads which perform a lot of concurrent mallocs,
// but it doesn't fit well to the JVM which has its own memory management
// and rather allocates fewer and larger chunks.
// Using only one arena significantly reduces virtual memory footprint and
// fragmentation. Saving memory seems to be more valuable for the JVM than
// optimizing concurrent mallocs.
#ifdef __GLIBC__
if (GlibcMallocArenas > 0) {
mallopt(M_ARENA_MAX, GlibcMallocArenas);
}
#endif

if (PosixSignals::init() == JNI_ERR) {
return JNI_ERR;
}
Expand Down
Loading