• jmap(Java Virtual Machine Memory Map)、jhat(Java Heap Analysis Tool)

1,jmap查看进程堆栈信息

# 1, 查看进程pid
hadoop1:/root # ps -ef |grep java
user1      14617 14480  1 Oct12 ?        12:19:37 /usr/java/jdk1.8.0_241-amd64/bin/java -Xms691m -Xmx691m -XX:MaxDirectMemorySize=333m 
		-Djava.io.tmpdir=./tmp -DpipelineId=full_chain_alert_4848095858075648
		-Dlog.file=/applog/eoi/core/hadoop/userlogs/application_1689668411021_0648/container_e27_1689668411021_0648_01_000002/taskmanager.log
		-Dlogback.configurationFile=file:./logback.xml org.apache.flink.yarn.YarnTaskExecutorRunner --configDir . 
		-Dweb.port=0 -Denv.java.opts=-Djava.io.tmpdir=./tmp -DpipelineId=full_chain_alert_4848095858075648 
		-Djobmanager.rpc.address=tuser1hadoop32 -Dtaskmanager.memory.size=507343008b 
		-Dweb.tmpdir=/data/eoi/core/hadoop/dfs/tmp/nm-local-dir/usercache/user1/appcache/application_1689668411021_0648/container_e27_1689668411021_0648_01_000001/./tmp/flink-web-a0828836-2ef1-462b-baa5-7e1679295f18 
		-Djobmanager.rpc.port=35103 -Drest.address=Tuser1HADOOP32

# 2,查看进程堆栈信息
hadoop1:/root # jmap -heap 14617
Attaching to process ID 14617, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.241-b07

using thread-local object allocation.
Parallel GC with 8 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 0
   MaxHeapFreeRatio         = 100
   MaxHeapSize              = 725614592 (692.0MB)
   NewSize                  = 241696768 (230.5MB)
   MaxNewSize               = 241696768 (230.5MB)
   OldSize                  = 483917824 (461.5MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 222298112 (212.0MB)
   used     = 50826216 (48.471656799316406MB)
   free     = 171471896 (163.5283432006836MB)
   22.863989056281323% used
From Space:
   capacity = 9961472 (9.5MB)
   used     = 3949088 (3.766143798828125MB)
   free     = 6012384 (5.733856201171875MB)
   39.6436189350329% used
To Space:
   capacity = 9437184 (9.0MB)
   used     = 0 (0.0MB)
   free     = 9437184 (9.0MB)
   0.0% used
PS Old Generation
   capacity = 483917824 (461.5MB)
   used     = 31306744 (29.85643768310547MB)
   free     = 452611080 (431.64356231689453MB)
   6.4694339508354215% used

18563 interned Strings occupying 1917064 bytes.

2,生成coredump文件,并查看


# 1, 根据pid,生成dump文件
hadoop1:/root # jmap -F -dump:format=b,file=/tmp/a.dump 14617
Attaching to process ID 14617, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.241-b07
Dumping heap to /tmp/a.dump ...

# 2,使用jhat 读取dump文件
hadoop1:/root # jhat /tmp/a.dump 
Reading from /tmp/a.dump...
Dump file created Wed Nov 08 11:09:42 CST 2023
Snapshot read, resolving...
Resolving 0 objects...
WARNING:  hprof file does not include java.lang.Class!
WARNING:  hprof file does not include java.lang.String!
WARNING:  hprof file does not include java.lang.ClassLoader!
Chasing references, expect 0 dots
Eliminating duplicate references
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐