toy
toy

Reputation: 12141

Am I reading this top command correctly?

I'm trying to debug how much of memory my java process consumes. Please correct me if I'm wrong.

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
11798 root      20   0 17.354g 6.084g 164456 S  38.9 10.2  12:52.04 java

This is the process. And this is how I start that java application

'-server -Xmx10G -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps'

As you can see that I'm giving that application 10G of memory. But according to top help page %MEM is the percentage of actual memory usage. In this case, I'm assuming that it's only using 10% of 10G?

The reason I'm asking this because, I might want to reduce the -Xmx down to 3GB if it's only using 1GB, then giving it 10G is going to be a bit of overkill.

My question is, am I correct in assuming that 10% is the actual usage of the memory of that process so I lower -Xmx option so other process can get some more memory.

Upvotes: 2

Views: 203

Answers (1)

Umar Ashraf
Umar Ashraf

Reputation: 192

No, 10.2% in %MEM column doesn't mean its 10.2% of what JVM is allocated. "top" is unaware of what JVM startup options you use. The man page for "top" defines %MEM as

"A task's currently used share of available physical memory."

So its the total available system memory(physical not virtual).

Upvotes: 1

Related Questions