Is it possible to query a collection that is dumped in a heap dump? I can obviously browse that collection using something like Eclipse MAT, but would really love to be able to actually call a getter on the collection object. This would obviously be a lot clearer than going through segments in a ConcurrentHashMap trying to find the mapping I need.
I suppose what I’m looking for is some way to ‘rehydrate’ the dumped state of a named collection so that it can then be manipulated using the standard APIs.
Does anyone know of any such utilities, or, if not, can someone provide some sample code or pointers as to how to achieve this?
You should be able to query all collections or single one with Object Query Language (OQL) in jhat.
You can’t necessarily invoke arbitrary methods but you can write some complicated queries using the available functions.
A. Sundararajan has some interesting blog posts on the subject that showcase what you can do. See here and here.
For instance, you can find all instances of
java.util.HashMapthat have a key test with the following query:This should find the same key in a
java.util.concurrent.ConcurrentHashMap: