如何在Eclipse中保存堆(转储到文件)? [英] How do I Save the Heap (Dump to a File) in Eclipse?

查看:548
本文介绍了如何在Eclipse中保存堆(转储到文件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从MyEclipse运行或调试我的GA / AI时出现此错误:



线程main中的异常java.lang.OutOfMemoryError:Java堆空间



eclipse.ini如下所示:

  -showsplash com .genuitec.myeclipse.product 
--launcher.XXMaxPermSize 256m
-vmargs
-Xms128m
-Xmx512m
-Duser.language = en
-XX :PermSize = 128M
-XX:MaxPermSize = 256M

MyEclipse的调用如下:

 C:\Program Files \ Myyclipse 6.0 \ eclipse \ eclipse.exe-vmC:\ Program Files\MyEclipse 6.0 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 

将vm设置提升到这个位置:

 C:\Program Files \ Myyclipse 6.0 \ eclipse \\ \\ eclipse.exe-vmC:\ Program Files \ Myyclipse 6.0 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ p $ p> 

没有效果。所以我试图让它将堆转储到一个文件,但放置这些:

  -XX:+ HeapDumpOnCtrlBreak 
-XX:+ HeapDumpOnOutOfMemoryError

在程序参数中没有任何效果。如何使用更多的内存使用情况分析?例如,jstack目前在Windows平台上不可用。并且使用SendSignal没有我能看到的效果。



解决方案

有很多方法可以获得堆转储。以下是我使用的一些:


  1. -XX:+ HeapDumpOnOutOfMemoryError 如果你点击你的OOM,会让你转储。

  2. VisualVM (免费)并使用其GUI强制进行堆转储

  3. 使用许多优秀的商业剖析器之一(JProfiler,YourKit,...)

  4. 使用jmap(见下文)强制正在运行的进程转储

如果你正在运行Java 6, jmap 应该适用于Windows。如果要转储堆并且没有命中OOM,这可能很有用。使用Windows任务管理器查找Java应用程序的pid,并在控制台中运行:

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

除了VisualVM, Eclipse Memory Analyzer (也是免费的)可以帮助您分析在转储后占用所有空间的内容。


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 like this:

-showsplash com.genuitec.myeclipse.product
--launcher.XXMaxPermSize 256m
-vmargs
-Xms128m
-Xmx512m
-Duser.language=en 
-XX:PermSize=128M 
-XX:MaxPermSize=256M

MyEclipse is called like this:

"C:\Program Files\MyEclipse 6.0\eclipse\eclipse.exe" -vm "C:\Program Files\MyEclipse 6.0\jre\bin\javaw.exe"  -vmargs -Xms1448M -Xmx1448M

bumping the vm settings up from this:

"C:\Program Files\MyEclipse 6.0\eclipse\eclipse.exe" -vm "C:\Program Files\MyEclipse 6.0\jre\bin\javaw.exe"  -vmargs -Xms80M -Xmx1024M

has had no effect. So I'm trying to get it to dump the heap to a file, but placing these:

-XX:+HeapDumpOnCtrlBreak
-XX:+HeapDumpOnOutOfMemoryError

in the Program arguments has had no effect. How do I get something to work with more memory usage analysis? jstack, for instance, is not currently available on Windows platforms. And using SendSignal has no effect that I can see.

解决方案

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 <pid>

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.

这篇关于如何在Eclipse中保存堆(转储到文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆