 <p>If you want to take a heap dump programmatically, you'll not find suitable APIs in the java.* or javax.* namespace. However, the Sun runtime comes with the <a href="http://java.sun.com/javase/6/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html" rel="nofollow noreferrer">HotSpotDiagnosticMXBean</a> which will enable you to take a heap dump by writing the contents of the heap on to a specified file in disk.</p>