Recently I had a java.lang.OutOfMemoryError thrown on the command line when running an ant deployment and testing script. I tried to re-run the ant script with the -d flag hoping for more information but nada…
After a quick google search I discovered this nifty eclipse plugin called Eclipse Memory Analyzer. This plugin can analyze heap dump files for you and give you some hints about what could causing your problem.
- Send in VM argument to get the VM to produce a dump of the heap when you get an OutOfMemory error:
- This will produce a .hprof file when it encounters the java.lang.OutOfMemoryError
- In eclipse switch the Memory Analyzer perspective and select the .hprof file by going to File -> Open Heap Dump
- Once open you can run several analysis on the heap dump.
- I chose Leak Suspects report and got the following:
Notice it’s all StringBuffer, ByteStream info that seems to be the problem. Turns out that someone checked in a change to our log4j.properties that caused extra logging during our junit run. Quick fix to the log4j level and I was back in business.
Pretty useful tool!