How does a Java process with -Xmx1024m occupy 3 GB of resident memory?

This is a Java web application on Websphere6.1, Solaris 10, JDK 1.5.0_13. We set the maximum heap size to 1024 m. Jmap shows that the state of the heap is great. Heap memory usage is only 57%. No OutOfMemory at all.

But we saw a very high RSS (3GB) for this java process from ps. pmap shows a block with 1.9G private memory.

3785: / dmwdkpmmkg / was / 610 / java / bin / java -server -Dwas.status.socket = 65370 -X
 Address Kbytes RSS Anon Locked Pgsz Mode Mapped File
...
0020A000 2008 2008 2008 - 8K rwx-- [heap]
00400000 1957888 1957888 1957888 - 4M rwx-- [heap]
8D076000 40 40 40 - 8K rw - R [stack tid = 10786]
...

Is this a memory leak of the C heap in native code? What approach is recommended to find out the root cause?

+5
source share
4 answers

This Sun memory leak troubleshooting can help you find the problem why your RSS is high, especially in section 3.4.

When you use Websphere, perhaps you can use -memorycheck in your virtual machine. See here for more details .

This is not necessarily a leak in native code. If you look here , there may be a problem with open files on Solaris.

This is just a bunch of links and hints, but maybe useful for finding your problem.

+4
source

, (, zip).

. glibc >= 2.10

, env export MALLOC_ARENA_MAX=4

IBM MALLOC_ARENA_MAX https://www.ibm.com/developerworks/community/blogs/kevgrig/entry/linux_glibc_2_10_rhel_6_malloc_may_show_excessive_virtual_memory_usage?lang=en

Google MALLOC_ARENA_MAX SO, .

, malloc :

# tune glibc memory allocation, optimize for low fragmentation
# limit the number of arenas
# requires glibc >= 2.16 since there was a bug in 
# MALLOC_ARENA_TEST parameter handling that cause MALLOC_ARENA_MAX not to work
export MALLOC_ARENA_MAX=2
# disable dynamic mmap threshold, see M_MMAP_THRESHOLD in "man mallopt"
export MALLOC_MMAP_THRESHOLD_=131072
export MALLOC_TRIM_THRESHOLD_=131072
export MALLOC_TOP_PAD_=131072
export MALLOC_MMAP_MAX_=65536

malloc_info, . JNA malloc_info.

+3

Java, VM , .

Try running Hello World with a heap size of 1024 m and "for (;;)" in it and see how much it takes. This should give you a basic level for shared memory usage.

+2
source

Do you use JNI libraries? I'm not sure how native code allocates RAM, but where I start to search.

+1
source

All Articles