Q:

How to know memory used by a Java program

I have a program that runs on a server (using Jetty). I'm testing it right now. For that, I use a stress test platform called Gatling. To monitor, I use jconsole that is supposed to show me the memory, cpu ... usage of the JVM on the remote server. However, while running my tests, jconsole shows me that 500 Mo is used but using the top command on my server shows me that the java process is using almost 1 Gig.
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                  
2328 ubuntu    20   0 2627m 942m  12m S 98.9 57.0  57:33.23 java      

Well, I have troubles interpreting these results, I must misunderstand something here but can't figure out what.
Any help would be great,
Cheers

A:

the memory used by java process consists of

heap space (500 mb in your case)
permgen sizem which depends on your settings, should be 64mb by default
stack size 
JVM process size itself

take a look at the link for more details.

