Thursday, November 30, 2017
Java process consuming more memory than Xmx heap allocated
1. Behavior is the following:
Java has the following Xmx parameter set up for max heap size:
-Xmx24576m
2. Despite this a top command shows consumption bigger than that:
The above shows Resident Size (memory consumed by Java process) to be around 0.041 Terra = aprox 41 GB . This is far more than the allocated heap at step 1 - 24GB.
Note: Do not take into consideration the Virtual column, this memory is not the same with the one used by Java process.
3. If we do another test using command line, we get the same results:
ps aux | awk '{print $6/1024 " MB\t\t" $11 $12}' | sort -rn | head -n 1
It shows:
4. Our matter is confirmed, something else is getting memory space being occupied.
Additional pmap can be used to confirm our doubts - just to get memory consumed by anonymous block allocations:
pmap -x 4366 | grep anon | awk '{s+=$3} END {s=s/1048576 "MB";print s}'
5. One possible resolution to this (there are many solutions found over the Internet) is to tune glibc. It is known on Linux to have those kind of memory leaks.
Especially the parameter MALLOC_ARENA_MAX needs to be tuned, and a value of 2 is highly recommended:
export MALLOC_ARENA_MAX=2
More details about this variable here - a very good article to read:
https://siddhesh.in/posts/malloc-per-thread-arenas-in-glibc.html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment