Export (or serialize) object from Java Heap Dump
Asked Answered
P

0

9

I have a heap dump from a (formerly) running Java process. At the time the dump was taken, the process was hung communicating with another server. I would like to be able to reconstruct the exact request that was made by my application.

Although my client communicates with a SOAP web service, the model object happens to be Serializable, so what I would like to do is export the request object (using its Serializable form if possible) and then I can easily re-import that object (just deserialize it) into a test application.

My problem is that I can't find a way to export objects from the heap dump. I am able to locate the object in question using OQL, so I know it's there - I just can't find any tools that offer any way of getting objects out of a heap dump.

Since my class happens to be Serializable I figured that would be easiest. But if I could get it out in any other parsable format, I could programmatically reconstruct the object.

Ideas?

Punke answered 19/7, 2013 at 21:9 Comment(3)
Objects are not sorted in the dump in a Serializable form. They are dumped in a form close to how it is stored in memory. You need to read the data to work out how to reconstruct the original object so it can be Serialized.Tiannatiara
@PeterLawrey That's fine, but it seems like this is a problem that lots of people might have. I'm surprised someone hasn't built a tool that can take a heap dump and an object ID (or however they are identified, whatever my OQL query gives me) and spits out a file in any format (Serialized object, XML, JSON, some sort of text description, whatever)Punke
Normally when you want data from a program you code it that way. In my programs I log to a file all the information I might want later in a binary format which is easy to read in a real-time way. Taking a heap dump to get one object doesn't sound very efficient and hard to automate as you have found.Tiannatiara

© 2022 - 2024 — McMap. All rights reserved.