Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

是什么东西占用内存java

如何找到jvm是什么东西占用内存 。

java启动参数非常简单java -Xmx512m -jar app.jar。

在容器内执行top 看到java占用内存是2.7g

是啥东西占用了这么大的内存呢 ?

top -p 1
1 root 20 0 12.439g 2.774g 14476 S 1.7 9.1 671:34.87 java

root@ip-10-10-29-126:/# jmap -heap 1
Attaching to process ID 1, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.131-b11

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

Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 536870912 (512.0MB)
NewSize = 169869312 (162.0MB)
MaxNewSize = 178782208 (170.5MB)
OldSize = 339738624 (324.0MB)
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 = 29884416 (28.5MB)
used = 5469080 (5.215721130371094MB)
free = 24415336 (23.284278869628906MB)
18.300775896038925% used
From Space:
capacity = 5242880 (5.0MB)
used = 1917696 (1.828857421875MB)
free = 3325184 (3.171142578125MB)
36.5771484375% used
To Space:
capacity = 5242880 (5.0MB)
used = 0 (0.0MB)
free = 5242880 (5.0MB)
0.0% used
PS Old Generation
capacity = 294125568 (280.5MB)
used = 89894072 (85.72966766357422MB)
free = 204231496 (194.77033233642578MB)
30.56316137738831% used

37045 interned Strings occupying 3813048 bytes.

root@ip-10-10-29-126:/# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

可以使用jmap 导出dump,使用mat工具分析一下哪些类占用的内存比较多。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...