explain high virtual memory claimed by Java process

Thomas Stüfe thomas.stuefe at gmail.com
Wed Aug 8 06:09:01 UTC 2018


Hi Tao

On Wed, Aug 8, 2018 at 4:40 AM, Tao Mao <yiyeguhu at gmail.com> wrote:
> Hi gc exports,
>
> I have a Java  application with following JVM options:
> "-Xms128m -Xmx256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m"
>
> When I use top to check memory usage, I got a very high virtual memory but a
> reasonable resident memory as below:
>
> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> 93704 root 20 0 11.4g 477m 19m S 0.0 0.1 26:53.65 java
>
> I understand the claimed virtual memory can be more than heapsize +
> metaspaceSize due to overheads in JVM implementation. I would expect this
> number to be a couple times of the size (heapsize + metaspaceSize) at most.
> But in this case it's >20 times.
>
> The claimed virtual memory usually is comprised of heap size, metaspace
> Size, and stack space. Could someone explain what else can contribute to
> this high markup? Thanks.
>

just taking a wild guess here. Do you have an abnormal high number of threads?

(if this is on Linux: cat /proc/<pid>/status | grep Threads)

High virtual size may be caused by a high number of threads which do
not do much and hence only use the first few pages of their thread
stacks. With 1M default stack size for java threads a few thousand
threads may explain your large virtual size.

Note this is just one of many possible explanations fitting your scenario.

> # java -version
> java version "1.8.0_172"
> Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
> Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
>

This is the commercial Oracle JDK, not OpenJDK.

> Regards,
> Tao Mao
>

Best regards, Thomas

> _______________________________________________
> hotspot-gc-use mailing list
> hotspot-gc-use at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use
>


More information about the hotspot-gc-use mailing list