4
votes

I'm helping develop a java application using my Windows 7 machine, which has Java 8 Update 45. I'm noticing a substantial difference in how much memory Windows Task Manager says is being used by the application (through the javaw.exe Image), and what Eclipse Memory Analyzer/Java Mission Control reports.

Example: Java Mission Control reports 150 MB of Java Heap Memory used, while Windows says 303 MB of Working Set used for javaw.exe. I understand there is probably some overhead for JVM itself, GC, etc.

But I also see it doing GC. After a bit of clicking around to make memory grow, JMC shows GC was performed and says 200 MB of heap used. Windows reports 619 MB (it never went down). Is Windows not displaying memory usage by Java properly? Something with the application cause this to happen?

1

1 Answers

4
votes

When the JVM starts up, it allocates a continuous region of memory for the heap. This memory can be turned into real memory lazily but almost never is passed back to the operating system.

The heap is but one region of memory the JVM uses. It may be the most important to you but when your heap is really small, it can be small compared to the other regions the JVM uses. This includes

  • native memory e.g. direct ByteBuffers.
  • GUI native components.
  • shared libraries.
  • the jar files.
  • the metaspace (or perm gen)
  • the thread stack memories.

Is Windows not displaying memory usage by Java properly?

Windows shows all the memory used, not just the portion used by the heap.

Something with the application cause this to happen?

Windows has no idea how much of the maximum heap size you are using.