0

the memory displayed by linux top command

the heap usage of the same jvm


The memory usage of the same program displayed by them are so different. Is there some thing other cost the memory ?

Brutal_JL
  • 2,839
  • 2
  • 21
  • 27
  • 1
    The heap is just one memory region in the JVM and just because only 50% of the maximum heap size is used, doesn't mean that the other 50% has been freed to the OS. It appears your maximum heaps 3.0 GB and you have about 0.4 GB in shared libraries, thread stack etc. i.e. it looks normal to me. – Peter Lawrey Jun 07 '16 at 05:06

2 Answers2

3

The memory usage of the same program displayed by them are so different. Is there some thing other cost the memory ?

Yes. Java allocates its' memory in large blocks and manages those blocks internally (as a single process). The linux top command only sees the JVM as a whole (not the internal memory usage). For that, use jconsole; which is showing how much memory is available (within the JVM).

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
1

As an aside, you can also get JVM OS process total memory usage from the OperatingSystemMXBean.

Nicholas
  • 15,916
  • 4
  • 42
  • 66