开发一个需求,内存中需要一些缓存对象,需要先预估下能装多少对象。。 查看JVM参数信息
jinfo -flags [pid]
Attaching to process ID 26841, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.45-b02
Non-default VM flags: -XX:CICompilerCount=15 -XX:ConcGCThreads=7 -XX:+DisableExplicitGC -XX:G1HeapRegionSize=2097152 -XX:G1ReservePercent=25 -XX:GCLogFileSize=134217728 -XX:+HeapDumpOnOutOfMemoryError -XX:InitialHeapSize=4294967296 -XX:InitiatingHeapOccupancyPercent=30 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=4294967296 -XX:MaxNewSize=2575302656 -XX:MinHeapDeltaBytes=2097152 -XX:NumberOfGCLogFiles=5 -XX:+PrintGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:+UseGCLogFileRotation
Command line: -XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+DisableExplicitGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=128M -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Dfile.encoding=UTF-8 -Xms4g -Xmx4g -Dspring.profiles.active=pro -Dhome.dir=/application-test -Xloggc:/application-test/logs/gc.log -javaagent:/pinpoint-bootstrap-1.6.2.jar -Dpinpoint.applicationName=application-test -Dpinpoint.profiler.collector.ip=local -Dpinpoint.profiler.sampling.rate=200
查看G1堆的使用情况
jmap -heap [pid]
Attaching to process ID 26841, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.45-b02
using thread-local object allocation.
Garbage-First (G1) GC with 28 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 4294967296 (4096.0MB)
NewSize = 1363144 (1.2999954223632812MB)
MaxNewSize = 2575302656 (2456.0MB)
OldSize = 5452592 (5.1999969482421875MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 2097152 (2.0MB)
Heap Usage:
G1 Heap:
regions = 2048
capacity = 4294967296 (4096.0MB)
used = 2276079248 (2170.6383209228516MB)
free = 2018888048 (1925.3616790771484MB)
52.994099631905556% used
G1 Young Generation:
Eden Space:
regions = 623
capacity = 2181038080 (2080.0MB)
used = 1306525696 (1246.0MB)
free = 874512384 (834.0MB)
59.90384615384615% used
Survivor Space:
regions = 43
capacity = 90177536 (86.0MB)
used = 90177536 (86.0MB)
free = 0 (0.0MB)
100.0% used
G1 Old Generation:
regions = 462
capacity = 2023751680 (1930.0MB)
used = 879376016 (838.6383209228516MB)
free = 1144375664 (1091.3616790771484MB)
43.45276274211666% used
34128 interned Strings occupying 3654448 bytes.