Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a "memory dump" of java application?

I have Java application, which, unfortunately, begins to consume quite big amounts of memory after some time. To complicate things, it's not only Java application, it is also JavaFX 2 application.

I suspect that there is some memory leak, maybe even in underlying JavaFX calls and native libs.

The ideal solution would be to get a dump of all java objects at some moment (with their memory usage), and then analyze that dump. Is there some way to achieve this?

like image 211
Rogach Avatar asked Aug 18 '12 12:08

Rogach


People also ask

How do I make a heap dump?

Start the administrative console. In the navigation pane, click Troubleshooting > Java dumps and cores. Select the server_name for which you want to generate the heap dump. Click Heap dump to generate the heap dump for your specified server.

What is Java heap dump?

A heap dump is a snapshot of all the objects in the Java Virtual Machine (JVM) heap at a certain point in time. The JVM software allocates memory for objects from the heap for all class instances and arrays.

What is memory heap dump?

A heap dump is a snapshot of all the objects that are in memory in the JVM at a certain moment. They are very useful to troubleshoot memory-leak problems and optimize memory usage in Java applications. Heap dumps are usually stored in binary format hprof files.


1 Answers

Use jmap -heap:format=b <process-id> to create a binary dump of the heap which can then be loaded into several tools - my favorite being the "Eclipse Memory Analyzer"

like image 154
pjklauser Avatar answered Sep 19 '22 22:09

pjklauser