Find the memory leaks in your app with Eclipse Memory Analyzer ( MAT ). This Eclipse plugin can give you a detailed view on object level of memory consumption in the JVM of your application.
When you are dealing with a OutOfMemoryErrors , a slow process or your just refactoring your application MAT analyzes for you a heapdump from the JVM and can give you insight where to look. Here are some screenshots from a heapdump.
The plugin has really a ton of options, look on http://www.eclipse.org/mat/ for more info.
How do you obtain an memory dump from the JVM you are now thinking probably.
Well, there are several options.
- If you have started your JVM with the argument
-XX:+HeapDumpOnOutOfMemoryErroryou get dumps in the case you have OutOfMemoryErrors
-XX:+HeapDumpOnCtrlBreakto your JVM will write a heap dump together with thread dump on CTRL+BREAK
- Use JConsole MBean HotSpotDiagnostic to force a heap dump with the dumpHeap operation.
! Last option works only with JDK 6. Give the name of the file as first argument to the operation. The dump is written in the home directory of the user on a Linux OS. (Do not know how it works on Windows )