Understanding Memory Usage for Jetty

I have a Jetty server that I use for websocket connections for the application I'm working on. The only problem is that Jetty consumes too much virtual memory (! 2.5 GB virtual memory) and about 650RES.

My problem is that, as mentioned above, most of the memory (about 12 GB) is not the size of the heap, so its analysis and understanding of what is happening is more difficult.

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

I would like to confirm what I mean by virtual memory (because my understanding may be wrong). Virtual memory is "VIRT" when I run from above. 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!

+6
source share
2 answers

Insert the JVM options that you use at startup. You can configure the maximum memory used by the JVM with the -Xmx option, as already mentioned.

Your application uses only 603 MB of reserved memory. So it doesn't seem like it should bother you. You can get detailed memory usage information using "jmap", enable jmx and connect via jconsole or use the profiler. If you want to stay in * nix land, you can also try "for free" if your OS supports it.

In your case, Jetty does NOT take up 12.5 gigabytes of memory. It takes up 603 MB. Google for β€œvirtual memory,” for example, and you should get a lot of information about the difference between virtual and reserved memory.

+4
source

In a 64-bit environment, virtual memory has no value, so I'm not sure what the problem is. Resident memory is 650 MB or 1.3% of MEM. It is not clear that he uses a lot of 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 may find that the default heap size is 12 GB, and with some shared libraries, threads, etc. This may result in a virtual memory size of 12.5 GB. This does not mean that you have a memory leak or you even have a problem, but if you prefer, you can reduce the maximum heap size.

By the way: you can buy 32 GB for less than $ 200. If you have little memory, I would buy some more.

+1
source

All Articles