Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Memory : Why memory on task manager difference with JProbe (or JConsole tool)

The problem that I faced is my application's memory used is only 100MB after that it decreased 50MB, but on Window Task Manager it showed 150MB and always keep or increase but not decrease, How can we reduce Memory (Private working set) on task manager ?

like image 705
manhnt Avatar asked Aug 18 '12 09:08

manhnt


People also ask

Why JVM use more memory than XMX?

What you have specified via the -Xmx switches is limiting the memory consumed by your application heap. But besides the memory consumed by your application, the JVM itself also needs some elbow room. The need for it derives from several different reasons: Garbage collection.

How is memory managed in JVM?

Memory Management in Java refers to allocating and deallocating memory to java objects which reside in areas called Stack and Heap. Java has an automatic memory deallocation system known as Garbage Collector.

Does JVM allocate memory?

JVMs allocate memory on an as needed basis from the operating system. Generally, when the JVM starts, it will allocate the minimum memory allocated (Xms) to the application that is running. As the application requires more memory, it will allocate blocks of memory until the maximum allocation (Xmx) has been reach.


1 Answers

What you are seeing in JConsole (or other monitoring tools) is the pattern the java memory is being used.

The memory of the JVM is usually divided among these areas (what you also see in monitoring tools).

  1. Heap memory which is for Java objects
  2. Non-heap memory which is the place where java stores loaded classes and metadata and the JVM code
  3. Native memory which is a part of memory reserved for dll's and native code of Java (very low level). Sometimes you could get a OOM in this area while you got enough heap memory (because as you increase the Max Heap size, it reduces the native memory available).

The windows task manager does not show that. It shows the whole memory used by your application (heap + non-heap+ native part).

Also note that usually processes that request more memory from OS, this memory is kept by them even when the actual application "frees" memory. These memory pages have been mapped as part of the processe's address space. So in your Task Manager you would not see a pattern of decreasing memory, but that would not indicate some memory leak from your application.
So you can not reduce the memory you see from task manager but the memory you see from the monitoring tool should decrease at some point, otherwise that could indicate a memory leak

like image 103
Cratylus Avatar answered Oct 24 '22 18:10

Cratylus