在tomcat上运行我的Java应用程序几天后,我在tomcat进程上获得了100%的CPU负载。我做了jmap
来检测全部内存。该应用程序仍会处理所有传入的TCP请求,但不会启动网页(由于内存已满)
为什么CPU要达到100%?是否因为运行Java垃圾收集器?但是为什么要花几个小时呢?我不得不手动终止启动tomcat的过程。
如何通过参数Xms
或Xmx
更好地设置tomcat内存?
using thread-local object allocation.
Parallel GC with 2 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = 536870912 (512.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 84410368 (80.5MB)
used = 84410368 (80.5MB)
free = 0 (0.0MB)
100.0% used
From Space:
capacity = 3670016 (3.5MB)
used = 0 (0.0MB)
free = 3670016 (3.5MB)
0.0% used
To Space:
capacity = 3670016 (3.5MB)
used = 0 (0.0MB)
free = 3670016 (3.5MB)
0.0% used
PS Old Generation
capacity = 715653120 (682.5MB)
used = 715497816 (682.3518905639648MB)
free = 155304 (0.14810943603515625MB)
99.97829898373111% used
PS Perm Generation
capacity = 78643200 (75.0MB)
used = 78253152 (74.62802124023438MB)
free = 390048 (0.371978759765625MB)
99.5040283203125% used
31605 interned Strings occupying 3556200 bytes.
答案 0 :(得分:1)
如评论中所述,当内存以这种方式破裂时,这很可能是由内存泄漏引起的。
检测到此问题的唯一方法是使用专用工具。
我建议您使用 JProfiler ,您可以找到有关如何查找内存泄漏的指南here。
希望这会有所帮助:)