Is it possible to instantiate a jvm from a heap dump?

heap-dump, java, jvm

Solution

No you can't. You would need things like the current position in each open file. That affects what data is returned on a simple sequential read. The restorer would need to open each file and get it to the correct position. That may not be possible for non-seekable streams.

Program specific serialization is a much more feasible path, then setup the program from there.

Also, as Heap Dumps are usually from OutOfMemory situtaions, recreating JVM from same would again throw OutOfMemoryException. If you are taking heap dump in between, then serialize your objects and restore them when you bring up jvm.

(contents copied from comments of this question, Authors almas-shaikh and patricia-shanahan)

Problem

Everyone knows that a heap dump can be obtained from a running JVM. Is the other way possible? Can we start a JVM using a heap dump? I have been having this question in mind for a long time now. If this is possible it would solve a lot of time and make thinks easy for a support engineer. It helps big time in cases where if we have to recreate some the rare problems our customer face. [Just imagine that the underlying hardware and Java runtime are the same and also all the supporting files are also present in the respective location in file system]. Added note: The intention of doing this is not when OOM occurs but at any given point after JVM starts.

Original source