PDA

View Full Version : High Virtual Mem usage by pure Java Process running on SUSE



unnisworld
28-Feb-2012, 05:06
I have a pure java process which is running on SUSE Linux installed on a VM (Vmware Virtual Machine). The max heap of java process is set to 128 MB.
What i am observing is,
- Virtual memory consumed by this process is very high, more than 900MB.
- The Resident memory is below 250MB.
- The process is running for days without any OOM issue. So, there is no java memory leak.
- The process does not use any JNI calls directly. So, chances of native memory leak is less (can happen only if JVM has some leaks).

I am not able to understand why the process is holding on to 900 MB of virtual memory. At present there is lot of swap space left on the machine.
Is the OS behaving lazy here by not reclaiming the virtual memory allocated to processes, until the OS runs out of virtual memory space?

More details about the process is given below -
The process spawns Java threads to handle incoming HTTP requests. I do not see any thread leaks (from thread dump).
It uses Java sockets to communicate to the back end in-memory cache store (Coherence).

Any suggestions on how to proceed with the investigation will be highly appreciated.

ab
28-Feb-2012, 06:01
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There's a big difference between the heap available to a JVM and the
memory used by Java for that same environment. heap is always going to
be less, maybe a lot less, than what the system actually has in use for
the Java process itself. As an example, your 'java' binary, its
built-in JARs, and all of the libraries that interface with the OS
reside outside of the heap, and anything those use directly will be
outside the heap. The heap is only there for use by the JVM, which
doesn't know/care about all of that stuff happening outside of it to
make it nicely cross-platform.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPTF+OAAoJEF+XTK08PnB5YXcQAI7sE9KLzx B3P+z0f2XGVvxx
rNrtYcHWXVWqPimI3yGqtYFoo0xzoxWfheKaMh0Kv5YQr/KCA1lgCLGvoWfpNQ1Q
CL5c4EI6WO2zUC2I9Uhd2fkgVD8hXkT9l1VUK7qMcRIHJlUEcw DbmV5Za2a7Al0A
84R6d0wFfagVGxXLtZTm/Ka1D5zQY/ES9i+Ao8EedRSljwhUZLgzW7CmVyaHinLW
47sZw47BHVf48BObfgHO0FeSAd/i0RY/t39RmtJPUSGGozNC+z3mttpY+jNVY6CL
XCnvH7gQ2mhbTDjoI+d2GixXv6wOfrHIQDv2VIiAH4BQK/yCWW2X0MOwlW8HHwLy
vEg0TScavW1DNHdKYIvkFeyQ1asNYBweJjS+K69AjmTgrmGguN Ogq1xMZ1fVCuso
jTbvz8YWSPGzxwox7O8cpoRqPpvwin8oVr3aMdLEnNRiKp4iHy ov68uGtmaFHl68
vn5v+BNhNchMhBK1rsBp/nedgcJgvpDglVDfzOnv0k262BvaHojij9ubmcYZeETy
PlCre/tBkTjnhJNOEhnHrM9bVbtWLKyn7q7yLOnuyUIuYTesPp7cIivN RnQN7YCX
8QmMhA1cj/fZH+CXWkpxBg7AEp5fPSk5CrcbadBNdzhwjzf68gmCFX7qcPl2 LyY/
LQdylMBy28pf5Z8TtqJr
=u0ix
-----END PGP SIGNATURE-----

unnisworld
28-Feb-2012, 10:02
ab, thanks for the reply. I should have been more specific. What is concerning is not the difference between heap memory allocated and the virtual memory size. It is the constant growth in virtual memory of this process which is seen as an potential problem. The load on this process is same throughout the day, but the VM size keeps on increasing. Attaching a graph below, which shows the virtual memory growth of this process taken from collectl output - http://www.flickr.com/photos/unnisworld/6937446297/

From /proc/<pid>/status i can see that it is VmData which is growing consistently.

ab
28-Feb-2012, 15:00
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm learning a bit from this:

http://serverfault.com/questions/138427/top-what-does-virtual-memory-size-mean-linux-ubuntu

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPTN31AAoJEF+XTK08PnB5fcYP/3GGFpTLbyl9EWhA78Pk0IHy
i6UKaimjzYm8PsNC+vadBaUjMHlb6AT6c69HSjxalcgr+AkHaE o0FwMVgxws2n6q
S4pO+iGtESfAGRSdTdlYl1XYtlOSS5/aUr9uDIDMC1mj/VM0WApX4NodciSW/fMf
9bzXrxiqa0RT2WxmiQqyeVYdIhBTfoHbaz8Lw7xOZqR2JRZegO yf9BbGKe1U2aJj
6XmNS2nP1WXMIndLe4LoXSVDclCvSDIeGZXILkvtkXDjaHYyb4 2yTRms/qy5r31Y
plHDl4ShWOTQdZ0dSUZL+J6mLCfbYXusjhDZ4iSAPm5/y0mlTMzR65YsIMnNnBYZ
kCNhRIiyEL4lTuo0IUy9TsE1QRrzEWMLZxnZeExBtFQgPXO3Bp +N8FfL5CdfUrxX
TlZt+7kcNypo8Q0jdFKaC8a5DSIxwoPgFT7wPxFYA/tF4eP0mHFUGDynUIcCiuVJ
LkfiCVKiwUFFMlb8+ON5IF42SOiDP7A9L2IiefQlC7HBBhtlx3 zZxr9+R5Z5+ooB
kZCAbbt83jXVYdRirUAfp6KHvWowFUGU4KkqFYl/Dnm4UShNey5H1+gqvyDjXhOm
Q9lw+jO7HGCO/ojiPB7H5ABLI0syCFg+1RLm0CSg6zojxAvDg/taDqpGs/zdj6JZ
Pzasuqjq4STJYCYl5RzG
=e3Kp
-----END PGP SIGNATURE-----

ab
28-Feb-2012, 15:35
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Another good post:

http://stackoverflow.com/questions/561245/virtual-memory-usage-from-java-under-linux-too-much-memory-used

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPTOZPAAoJEF+XTK08PnB52IAP/ix09RhmfA5EMkH5VO27iuE1
BruVHTdrEccM6VDtvyYI/YVuE0a5ImXTXfhV3XgCU8xU05s/NQSNVkly4XDbgvGV
Z3ujVZUpfPIgo5l+AQLFArFMDlS25IXhQcn00X0sythWj5GtZp DNUJvqOMv67iWU
7A0RMHnw1vaRymvtTGHqWlECBX8dbU32IQ9Jaa5X0kiwY9RB8F lhX8j38C1I4a6Q
isfvkgeMUFTDk4Tpgc+DiCJEDQADDVbkdGcWpHjUgRRPUfK7J2 PhcbmZb80qBBLQ
LhZVIUWRV1NilQy9oi3b0pRNtS654H28GFNnXrdW5C7GuQ7Sp5 YHovvPyZgpfiP0
sFOfBN5YbRElpHJjpEU3V8Z+P4r8bfGk85eM3LFb5NiIm8lKWO 2cbM98HdGLTEhB
iw65Ci+PeoZnzUmQGkRVUde9yEgzSXPAORI1CZ1uckUmpdMqnz GuFsTP/UEdR89x
Zp+S1CKit4ZdE74+l+rPcpKKa+vUwYsVafth4BCW3tjLu7d1Ba AywgfwelnC7VRh
b5dxWwpXa5mfvXZdnbxXkqCkuKX0ctJiuFRsf5A1qvk4gfrZtS fkM+2oYPFagnU0
PI9cjQtampitbrZhbR6hnQtLu3bVRrtdYb2P8CUiPx2NYBV+dQ c8phVjoLx3mnxT
dNjhmHfwLPqofZV8Fc/J
=fCnZ
-----END PGP SIGNATURE-----