[Red5devs] A great FREE memory leak tool for Java
Art Clarke
aclarke at vlideshow.com
Thu Oct 23 20:51:24 PDT 2008
Dan and I had a discussion about this last night and I claimed to him
that "we weren't really at the memory testing stage in our development
and so hadn't looked at tools for doing it".
Lo and behold, today, I spent the entire day chasing down memory
issues; spoke too damn soon.
Anyway, the net result was good for Vlideshow and we learned a lot.
But there was one trick that I want to share with the team, as it
makes finding leaks much EASIER under Java.
1) If you don't already, learn how to make your Java VM do a memory
heap dump. You can use jconsole, or hprof to do this. See here for
details:
http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/index.html
or here if you can't read ALL the detail:
http://blog.emptyway.com/2007/04/02/finding-memory-leaks-in-java-apps/
or just add this to the command line for a Java process that will exit
or throw an OutOfMemory error:
"-agentlib:hprof=heap=all,lineno=y,thread=y,format=b"
2) And then, once you have a dump, may I introduce a FREE plugin for
Eclipse that visualizes the data:
http://www.eclipse.org/mat/
You can find the largest objects, trace all references, find the
fastest path to the root, and other things.l Did I mention FREE?
Install, have it analyze a heap dump, and happy investigating. It
really helped me find and nail two memory leak issues in our software
right off the bat.
- Art
More information about the Red5devs
mailing list