Where to find the heap dump after an “Out Of Memory”

我是研究僧i 提交于 2019-12-10 14:49:45

问题


I'm using ASANT to run a xml file which points to a NARS.jar file.

I'm getting "java.lang.OutOfMemoryError: Java heap space" and i'm researching around this.

So i have found that i need to set "-XX:+HeapDumpOnOutOfMemoryError", to create a dump file to analyze.

I edited ASANT.bat and added the "-XX:+HeapDumpOnOutOfMemoryError" to ANT_OPTS:

set ANT_OPTS= "-XX:+HeapDumpOnOutOfMemoryError" "-Dos.name=Windows_NT" "-Djava.library.path=%AS_INSTALL%\lib;%AS_ICU_LIB%;%AS_NSS%" "-Dcom.sun.aas.installRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceName=server" "-Dcom.sun.aas.configRoot=%AS_CONFIG%" "-Dcom.sun.aas.processLauncher=SE" "-Dderby.root=%AS_DERBY_INSTALL%"  

But i can't seem to find any dump file. I will use the Eclipse Memory Analyzer to analyze when i find the dump.

I also tried to set the option "-XX:HeapDumpPath=c:\memdump\bds.hprof", but no dump was created there.

Anyone got an idea of what i'm doing wrong? Thanks in advance


回答1:


I found that i could use VisualVM from SUN to get a heapdump, and see it live.

Easy solution




回答2:


It's in the working directory of the application (i.e. where you've started it). I'm not sure what happens if the process does not have the necessary privileges to do so. Probably, writing the dump would fail silently.




回答3:


are you sure that ANT is the process with the OOME ? It may be a process started by ANT.

Add "-debug" to the ANT_OPTS for debugging information.

Are you seeing the targets being printed out during the execution?

You can also fork the various processes started by ant ( will slow things down but may help isolate the culprit )

Lastly, maybe you just need more memory than the default. Add:

-Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m

to the ANT_OPTS




回答4:


It looks like your application is running on Windows. A Windows file path needs to be escaped with \. As per your example, -XX:HeapDumpPath should look like:

-XX:HeapDumpPath=c:\\memdump\\bds.hprof

Besides ‘-XX:+HeapDumpOnOutOfMemoryError’ there are several other options to capture heap dumps as well.




回答5:


Umm... how about wherever java.io.tmpdir is pointing?



来源:https://stackoverflow.com/questions/2409427/where-to-find-the-heap-dump-after-an-out-of-memory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!