简体   繁体   中英

Java JVM parameter Xms doesn't take effect immediately

I run my Java Application through tomcat, and set the -Xms1024m, however I found the size of the Java heap just 200~300m after start the application, I think the Xms means the minimum heap size, why the application doesn't reach to the minimum Heap size 1024m immediately after the application startup?

Edit, BTW, the JVM is hotspot 7.0.

It seems the GC does it in the method HeapRegion::setup_heap_region_size(uintx min_heap_size) from the c++ file \\openjdk-7-fcs-src-b147-27_jun_2011\\openjdk\\hotspot\\src\\share\\vm\\gc_implementation\\g1\\heapRegion.cpp , and method parse_each_vm_init_arg from file \\openjdk-7-fcs-src-b147- 27_jun_2011\\openjdk\\hotspot\\src\\share\\vm\\runtime\\arguments.cpp , someone who familiar with JVM GC source code can help to do some analysis for it.

在此处输入图片说明

It only shows you the space used. The heap size determines the capacity of each region. Note: the actual size available is less as you have two survivors spaces and only one is active in normal operation. eg say you have a survivor spaces of 50 MB each, a 1 GB heap will say only 950 MB is available.

When you set the minimum heap size, this doesn't mean that space has been used yet. However you might not get a GC until this heap size is reached (or when the Eden which is a portion of the heap is full)

Say you have a 1 GB heap and the Eden space is 100 MB to start with. You will get a GC once the Eden fills up even though little tenured space is used. Eventually the Eden grows and the tenured space starts to fill and once it is full, it might grow the heap size to greater than the minimum heap size you gave it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM