user220755
user220755

Reputation: 4446

Understanding memory usage for Jetty

I have a Jetty server that I use for websocket connections for an app I am working on. The only issue is that Jetty is consuming way too much virtual memory (!2.5GB of virtual memory) and around 650RES.

My issue is that as mentioned above, most of the memory (around 12gb) is not the heap size so analyzing it and understanding what is happening is harder.

Do you have any tips on how to understand where the 12gb consumption is coming from and how to figure out memory leaks or any other issues with the server?

I wanted to clerify what I mean by virtual memory (because my understanding could be wrong). Virtual memory is "VIRT" when I run top. Here is what I get:

PID USER PR  NI  VIRT  RES  SHR S   %CPU %MEM  TIME+  COMMAND                                        
-------------------------------------------------------------                                        
9442 root 20 0   12.6g 603m  10m S   0    1.3   1:50.06 java

Thanks!

Upvotes: 6

Views: 10830

Answers (2)

Thomas Becker
Thomas Becker

Reputation: 944

Please paste the JVM Options you use on startup. You can adjust the maximum memory used by the JVM with the -Xmx option as already mentioned.

Your application has been using only 603MB reserved memory. So doesn't look like it should concern you. You can get some detailed information about memory usage by either using "jmap", enable jmx and connect via jconsole or use a profiler. If you want to stay in *nix land you can also try "free" if your OS supports it.

In your case Jetty is NOT occupying 12,5 gig of memory. It's occupying 603MB. Google for "virtual memory linux" for example and you should get plenty of information about the difference between virtual and reserved memory.

Upvotes: 5

Peter Lawrey
Peter Lawrey

Reputation: 533530

Virtual memory has next to no cost in a 64-bit environment so I am not sure what the concern is. The resident memory is 650 MB or a mere 1.3% of MEM. It's not clear it is using much memory.

The default maximum heap size is 1/4 of the main memory for 64-bit JVMs. If you have 48 GB of memory you might find the default heap size is 12 GB and with some shared libraries, threads etc this can result in a virtual memory size of 12.5 GB. This doesn't mean you have a memory leak, or that you even have a problem but if you would prefer you can reduce the maximum heap size.

BTW: You can buy 32 GB for less than $200. If you are running low on memory, I would buy some more.

Upvotes: 0

Related Questions