How do I Save the Heap (Dump to a File) in Eclipse?

前端 未结 3 1244
余生分开走
余生分开走 2021-02-06 14:32

I\'m getting this error when I run or debug my GA/AI from MyEclipse:

Exception in thread \"main\" java.lang.OutOfMemoryError: Java heap space

eclipse.ini looks l

3条回答
  •  清酒与你
    2021-02-06 14:51

    There are a number of ways to get heap dumps. Here are some I've used:

    1. -XX:+HeapDumpOnOutOfMemoryError should get you dump if you hit your OOM.
    2. Connect with VisualVM (free) and use its GUI to force a heap dump
    3. Use one of the many good commercial profilers (JProfiler, YourKit, ...)
    4. Use jmap (see below) to force a dump from a running process

    If you're running Java 6, jmap should work on Windows. This might be useful if you want to dump the heap and you haven't hit your OOM. Use Windows Task Manager to find the pid of your Java app, and in a console run this:

    jmap -dump:format=b,file=c:\heap.bin 
    

    In addition to VisualVM, the Eclipse Memory Analyzer (also free) can help you analyze what's eating up all the space once you've got the dump.

提交回复
热议问题