Sunday, March 13, 2016

linux - Understanding Java's memory usage (JIRA/Tomcat)



I have a CentOS virtualized server and I just installed Jira. I'm having trouble understanding what is going on with the Sun JVM whenever Jira is running. Java's max heap size is set to 384MB but the Java instance is taking up well over 1GB.



I'm new to linux server administration but I understand that their is additional overhead to the JVM and that process memory reporting isn't always accurate (especially with threads, which I believe Jira uses heavily), but I assume free -m gives a more accurate picture of total memory usage. Comparing the system memory with and without Jira tells me it is using over 1GB. I only have 1GB of physical ram and 768 swap/virtual.




When I use vmstat it says I have not had any virtual pages but I probably should be. I'm worried that I'm only running one process and my server is already maxed out. How can I be sure that my system is (or could be) on its knees because of resource usage?



Thanks.


Answer



Okay - there are a few things to keep in mind. First, in modern Linux kernels, threads are simply processes that share a few resources and flags, most notably, address space. So yep, threads in the output of something like 'top' can make things pretty confusing. Example: Our Oracle server has about 30 threads running simply appearing as 'oracle' - they each show up as consuming 38 GB of ram. Pretty amusing on first glance.



Ok - the suggestion in the comment above is spot on the money. Use 'pmap' to see exactly not just the memory consumption of the process, but the breakdown of that memory usage. The shared library entries (.so) entries aren't much to worry about. Your real concern is the [ anon ] entries and the [ stack ] entry. See if you can get a total of those. That will give you the honest picture of how much non-shared memory the process is consuming.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...