2

What are the possible causes for when the Linux top command shows a Java process is using 14GBs of memory while Java profiling shows only 2GBs being used?

Linux top command YourKit Java profiler

3
  • You can change this by supply xms related parameters when run java. BTW, i think they are talking different things: the memory jvm used/reserved and java application used. Commented Aug 16, 2017 at 2:51
  • The second picture of the Java profiler shows it has only allocated 2.1GB heap size, so xms should not matter. Commented Aug 16, 2017 at 2:53
  • You are right, I mean startup parameters will change top's result. Commented Aug 16, 2017 at 2:54

2 Answers 2

5

That means that your JVM / Java application is using off-heap memory. Lots of it.

  • It could be memory-mapped files.
  • It could be native libraries: unlikely ... for that much memory.
  • It could be memory allocated by native library (e.g. using malloc).
  • It could be huge numbers of Java threads, or threads with huge thread stacks.
  • It could be something else ...

It might be a memory leak of some kind, but it is not a memory leak of heap objects.

(The theory that it is due to -Xms is probably wrong. If the JVM preallocated a huge initial heap and didn't use it, you wouldn't expect that much "RES" memory. It is conceivable that the heap has gotten really big and has down-sized, but the JVM hasn't (yet) given the space back to the OS. But AFAIK the JVM releases the memory back to the OS when it downsizes the heap.)

If you are going to get to the bottom of this, you will need to understand what your application, and its library dependencies are doing.

Sign up to request clarification or add additional context in comments.

Comments

1

Your total memory is a result heap, PermSize and Stack size.

Max memory = [-Xmx] + [-XX:MaxPermSize] + number_of_threads * [-Xss]

Besides this JVM would also need some space to run smoothly. Explained here in deatil

1 Comment

That formula doesn't take account of the other things that can use a substantial amount of memory in a JVM. The article where you got it from tacitly acknowledges that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.