X

Sundararajan's Weblog

  • Java
    June 15, 2006

Java heap snapshot as a database?

Guest Author

Mustang is now packaged with Java DB. So, we have a database included in Mustang (Java SE 6). I am excited because...

Many of you would know jmap can dump snapshot of Java heap (of a live process or a java core dump) into a binary format file. Or alternatively hprof
profiler may also be used to dump heap snapshot.

The heap snapshot binary format (a.k.a hprof binary format) is described at

And you may already know that jhat (Java Heap Analysis Tool) can be used to analyze the heap dumps produced by jmap and hprof. jhat supports OQL (a SQL-like language) to query the heap.

Essential idea of jhat/OQL is this: heap snapshot is a database of objects. jhat parses the dump, creates in-memory object model, interprets query and generates result HTML.

How about this? - a new command line utility to "import" heap dump files into a database like Java DB. Then, we can use SQL to query the database - and it would be very easy to write tools on top of JDBC/SQL access. Besides, we can take advantage of the "large file" handling, indexing, query optimization aspects of the database - rather than having to implement similar stuff by jhat. Or may be, we can reimplement jhat as a tool that

  1. imports heap dump into a Java DB instance
  2. uses JDBC to query
  3. implements a web and/or swing front-end

Join the discussion

Comments ( 3 )
  • neoedmund Thursday, June 15, 2006
    it seems great. can it be a native java filesystem or java datebase?
  • Markus Kohler Friday, June 16, 2006
    Hi,
    Yes that might be a possibility. Also the question would be, whether it would be fast enough for large heaps. I've seen heaps with millions of objects.
    By the way the heap dump feature is now also available for JDK 1.4 and 1.5 See my blog at https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/u/6389
    Regards,
    Markus
  • A. Sundararajan Friday, June 16, 2006
    Yes, as Markus Kohler said heapdump JVM option(s) has been backported to HeapDumpOnOutOfMemoryError option in 5.0u7 and 1.4.2_12. Also, jmap heap dump feature has been backported to 1.4.2_09. Similarly jmap heapdump has been backported 5.0_05. Good thing is that Mustang's jhat can parse heap dumps from older releases such as 1.4.2_xx and 5.0_xx as well.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.