Java内存泄漏 [英] Java memory leak
问题描述
虽然 - XX:+ HeapDumpOnOutOfMemoryError 可以很有用,我目前使用Eclipse内存管理器的工作流程是: p>
- 正常运行程序
- 等待内存失控。
- 运行 jmap :
jmap -dump:format = b,file = dump.hprof< PID>
- 打开EMM中的hprof文件。 li>
我通常开始使用直方图和支配树视图来查看是否有任何东西似乎没有了,然后从那里向下钻取。 >
使用堆转储时,VisualVM可能很有用,但效率远低于EMM(EMM缓存了大量有关加载堆转储的信息)。 Netbeans Profiler非常适合获取分配位置和时间分析。
Has anybody used Eclipse memory manager to detect memory leak in java codes? Can anybody recommend a good place to look for information regarding using memory manager? I read something online, it suggests that i need to let the program run until it crashes (out of memory error occurs), which will generates a crash report. Then use the memory manager to open this report to examine where the memory leak might occur. Is this how everybody uses memory manager?
Though -XX:+HeapDumpOnOutOfMemoryError can be useful, my current workflow for using the Eclipse Memory Manager is:
- Run the program normally
- Wait for memory to get out of hand.
- Run jmap:
jmap -dump:format=b,file=dump.hprof <PID>
- Open the hprof file in EMM.
I usually start working with the histogram and dominator tree views to see if anything seems out of whack, then drill down from there.
VisualVM can be useful but seems much less efficient than EMM when working with a heap dump (EMM caches a lot of information on loading the heap dump). Netbeans Profiler is nice for getting the locations of allocations and for time profiling.
这篇关于Java内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!