I have these jvm param set
-Xms24g -Xmx24g -XX:+UseG1GC -XX:+AggressiveOpts -XX:+UnlockCommercialFeatures -XX:+UnlockExperimentalVMOptions -XX:InitiatingHeapOccupancyPercent=17 -XX:G1MaxNewSizePercent=75 -XX:+FlightRecorder -XX:+PrintCommandLineFlags
But In my heap statistics it shows . How can committed be more than Xmx?
in jconsole it shows values in GB
GB to GiB
Multiply by (1000³ / 1024³), equivalent to 0.931323
Divide by this value to go from GiB to GB
25.8*0.931323 = 24.0281334
Related
in my docker file
JAVA_OPTS = "-server -Xms512m -Xmx1024m -XX:HeapDumpPath=/opt/logs/dump"
ps aux | grep 18657
root 18657 29.6 4.5 4865248 1477012 ? Ssl 17:26 12:22 /usr/lib/jvm/default-jvm/bin/java -Djava.util.logging.config.file=/apache-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms512m -Xmx1024m
the thread memory 1477012 is more than 1G
so my question is : 600m more memory are noheap memory and how can i find out what is using it
also when i set JAVA_OPTS = "-server -Xms2048m -Xmx3072m -XX:HeapDumpPath=/opt/logs/dump"
when the docker container run and i find the java thread memory is less than 2g.
in my mind, xms is the start heap memory, java thread memmory using can not less the xms
In my java program I use java nio to communicate with another process, and my code doesn't allocate any direct ByteBuffer.
My code use an open source lib to communicate with another process with unix domain socket: https://github.com/jnr/jnr-unixsocket
and I use some jvm paramter to limit the memory size:
-Djdk.nio.maxCachedBufferSize=262144 -Xms80m -Xmx80m -Xmn40m -Xss256k -XX:NativeMemoryTracking=detail -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics -XX:MetaspaceSize=40m -XX:MaxMetaspaceSize=40m -XX:MaxDirectMemorySize=10m -XX:SurvivorRatio=2 -XX:TargetSurvivorRatio=90 -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=8 -XX:MaxTenuringThreshold=15 -XX:+PrintTenuringDistribution -XX:+UseParNewGC -XX:CMSFullGCsBeforeCompaction=5 -XX:+UseCMSCompactAtFullCollection -XX:+CMSPermGenSweepingEnabled -XX:CMSInitiatingOccupancyFraction=50 -XX:+CMSClassUnloadingEnabled -XX:+DisableExplicitGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps
how after several hours, the size of java process grows to more than 400MB
and I use jcmd to check the memory of the process
the total is about 200MB, so why the physical memory consumed by the java prcocess grow to a size much bigger than jcmd output?
I use java 8.
I start a tomcat instance enabled with jmx, I check G1 old gen memory stat, find max memory = max heap size.
The environment
# uname -a
Linux bogon 2.6.32-642.15.1.el6.x86_64 #1 SMP Fri Feb 24 14:31:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/redhat-release
CentOS release 6.8 (Final)
# java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
jvm option
# ps -ef|grep tomcat
tomcat 3177 1 7 10:23 ? 00:00:06 /usr/java/jdk1.8.0_65//bin/java -Djava.util.logging.config.file=/apps/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms1696m -Xmx1696m -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=200 -XX:+UseStringDeduplication -XX:MetaspaceSize=96m -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=45 -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintClassHistogram -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/tomcat/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=2M -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8415 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.rmi.port=8415 -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/apps/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/apps/tomcat/temp org.apache.catalina.startup.Bootstrap -Dprocessname=tomcat start
jmap result
# jmap -heap 3177
Attaching to process ID 3177, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.65-b01
using thread-local object allocation.
Garbage-First (G1) GC with 1 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1778384896 (1696.0MB)
NewSize = 1363144 (1.2999954223632812MB)
MaxNewSize = 1066401792 (1017.0MB)
OldSize = 5452592 (5.1999969482421875MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 100663296 (96.0MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 1048576 (1.0MB)
Heap Usage:
G1 Heap:
regions = 1696
capacity = 1778384896 (1696.0MB)
used = 84934656 (81.0MB)
free = 1693450240 (1615.0MB)
4.775943396226415% used
G1 Young Generation:
Eden Space:
regions = 81
capacity = 93323264 (89.0MB)
used = 84934656 (81.0MB)
free = 8388608 (8.0MB)
91.01123595505618% used
Survivor Space:
regions = 0
capacity = 0 (0.0MB)
used = 0 (0.0MB)
free = 0 (0.0MB)
0.0% used
G1 Old Generation:
regions = 0
capacity = 1685061632 (1607.0MB)
used = 0 (0.0MB)
free = 1685061632 (1607.0MB)
0.0% used
12869 interned Strings occupying 1777832 bytes.
Question
The jmx item java.lang:type=MemoryPool,name=G1 Old Gen,Usage.max is 1778384896, it equals to the max heap size.
If Old gen memory is not enough, all heap memory will be used for Old gen memory?
I really faced the same issue, that the max memory of old gen is as the same as the value of -Xmx, while the max memory of eden and survivor are both -1 (unlimited) in JMX interface. Just 5 months after your question, there was an issue ticket for openjdk "Revamp G1 JMX MemoryPool and GarbageCollector MXBean definitions". I'm afraid we can only be waiting for it being resolved.
I've got an app which is running on JBoss. The server's RAM is too low (about 2gb), so I need to decrease Java heap size. Also I've got 2 versions of Java : system version(1.4.2) and 1.7.0 for JBoss 7 only.
So, how can I decrease Java heap size properly?
There are two flags to control the heap size: -Xms128m will start your heap at 128 megs, and -Xmx1g controls the maximum size (here, it would set it to 1 gig).
You can change the heap size in jboss startup file, edit bat or sh file and search for -Xms and change it to your required size.
Default size of Heap space in Java is 128MB on most of 32 bit Sun's JVM and default values of heap size parameters on 64-bit systems have been increased up by approximately 30%.
You can use
java -XX:+PrintFlagsFinal -version | grep HeapSize
to check your default size.
Read more
You can change size of heap space by using JVM options -Xms and -Xmx. Xms denotes starting size of Heap while -Xmx denotes maximum size of Heap in Java.
You can use
java -Xms1024M -Xmx2048M YourApp
Or edit the /bin/run.sh|exe file by searching for “Sun JVM memory allocation pool parameters” and changing the JAVA_OPTS line:
set JAVA_OPTS=%JAVA_OPTS% -server -Xms1152m -Xmx1152m -XX:MaxPermSize=128m
-XX:MaxNewSize=128m
I am running Tomcat 6 on Linux and set Xms and Xmx in setenv.sh. After starting the Tomcat server I don't see the memory usage increased by at least specified in Xms.
Before startup free -m is showing 1500 as free memory.
In my startup.sh I can see memory settings.
CATALINA_OPTS: -Xms512m -Xmx1024m
After server startup free -m is showing 1140 as free memory. Why free memory is not reduced by at least 512m?
jinfo 14064 is showing VM Flags: -Xms512m -Xmx1024m
jmap -heap is also showing memory settings are applied
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1073741824 (1024.0MB)
Is there anything I am missing?
free -m command
http://www.linuxtoday.com/upload/understanding-free-command-in-linuxunix-130530185004.html
This command will show Actual free RAM.
RAM memory and Virtual memory are different.
Actual initial heap size and max heap size can be allocation by heap
could be identified with the following command.
add the following jvm argument -verbose:gc
and restart the server. Once the server is restarted and after initialization the verbose logs shows the following
// attribute name="maxHeapSize" value="0x40000000"
//attribute name="initialHeapSize" value="0x20000000"
Converting the value into the MB it will show the Xms and Xmx allocation.
Above shown is the snippet of the following command
java -Xms512M -Xmx1024M -verbose:gc -version