Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Process vs JVM Heap memory usage

I have read through this Process Memory Vs Heap -- JVM and i have the same problem.

The jvm process memory usage keeps increasing and never shrinks.I checked by doing a top on the linux server. The application is scheduling jobs to a cluster ( Using Quartz + Sun Java DRMAA API )

The java heap space is staying within the limits during the application life cycle but the jvm process is showing a steady climb in memory usage and never coming down.

Is this a memory leak ? If so , why is heap space being within the limits. Can someone explain this.

UPDATE: I have -Xmx1600m -Xms1600m when i track through jconsole i can see the heap space well within this limit aroung 450m but the top command shows the process is using more than 900m.

like image 300
Kathir Avatar asked Jul 22 '11 04:07

Kathir


People also ask

Is JVM memory the same as heap memory?

The Java Virtual Machine has memory other than the heap, referred to as Non-Heap Memory. It is created at the JVM startup and stores per-class structures such as runtime constant pool, field and method data, and the code for methods and constructors, as well as interned Strings.

What is JVM process memory?

The JVM divides its memory into two main categories: heap memory and non-heap memory. Heap memory is the part with which people are typically the most familiar. It's where objects that are created by the application are stored. They remain there until they are no longer referenced and are garbage collected.

Why does my Java process consume more memory than XMX?

But in 99% of the cases it is completely normal behaviour by the JVM. 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.

What is JVM heap usage?

Matthew NeSmith / Nov 11, 2020. The Java heap is the area of memory used to store objects instantiated by applications running on the JVM. When the JVM is started, heap memory is created and any objects in the heap can be shared between threads as long as the application is running.


2 Answers

The total virtual memory used is the sum of the maximum heap + thread stacks + direct memory + perm gen + share libraries. This never shrinks.

The actual main memory used depends on how much of the virtual memory has been occupied. Shared libraries are shared so having multiple JVMs won't result in this memory doubling etc.

The JVM never releases memory to the OS, however if main memory is not used for a long time it can be swapped out if this is need.

like image 148
Peter Lawrey Avatar answered Sep 18 '22 09:09

Peter Lawrey


The actual memory consumption is more than what what you set with Xmx etc, that's normal. "java will allocate memory for other things, including a stack for each thread. It is not unusual for the total memory consumption of the VM to exceed the value of -Xmx."

like image 20
ApriOri Avatar answered Sep 21 '22 09:09

ApriOri