Monday, January 30, 2012

I'm at it again. ReentrantLock$NonfairSync seems to be too abundant. I use MAT, which seems to have a somewhat different OQL than jVisualVM (having tried queries that work in one in the other). The MAT OQL pane opens up with a comment '/* press F1 for help */ in the edit area. Pressing F1 brings up no visible help. Maybe the hope of help is supposed to be sufficient?

I seem to have lost some notes from last time -- this doesn't improve the odds so much. Gr.

Reading documentation more, I'm trying things like:

SELECT OBJECTS inbounds(o) FROM (SELECT OBJECTS inbounds(nfs) FROM java.util.concurrent.locks.ReentrantLock$NonfairSync nfs) o
  WHERE classof(o).getName() LIKE "java.util.concurrent.ConcurrentHashMap.*"

Which still doesn't work, but seems closer. I get a ClassCastException with a message 'Remember: sub queries with the modifier INSTANCESOF or INCLUDING SUBCLASSES must return only class objects.'

Hah! That would imply someone told me to start with. So, reading the code a little it appears that subqueries may only return classes (which is a little what that error says, but it leaves room to hope I just did it wrong. No, it appears I can't do it).



However, simplifying to this:

SELECT OBJECTS inbounds(o) FROM (SELECT nfs FROM java.util.concurrent.locks.ReentrantLock$NonfairSync nfs)
  WHERE o.getName() LIKE "java.util.concurrent.ConcurrentHashMap.*"

works no better: Sub-Select must return an object list: (gives the sub select).

So, if sub-selects can only return classes they're really not so useful for me -- I want to select objects by what refers to them.

Have I mentioned that OQL implementations vary? So these nice posts (querying_java_heap_with_oql and permanent_generation_analysis_with_oql) are not so useful. Not to mention that many of their links don't work. 

Friday, November 11, 2011

Looking for a few good mbeans

Looking for my MBeans, since they don't seem to be where I expect them, leads me to OQL in the Eclipse Memory Analyzer. The documentation is terrible, really. Things don't seem to work as advertised, except that sometimes they do. The errors are very obscure, and the similarity to SQL may be more trouble than help.

So, I'm trying to find my beans with a query like this:
SELECT OBJECTS inbounds(nob) FROM com.sun.jmx.mbeanserver.NamedObject nob WHERE classof(nob.object).getName() NOT LIKE "org.apache.*"

And that does indeed work: they exist. The 'not like org apache' is because tomcat has beans too: they're nice, but I don't actually care about them now.

I'd like to find the MBeanServer instance that 'owns' them, so I started trying to follow the inbound references, but here:

SELECT OBJECTS inbounds(hme) FROM java.util.HashMap$Entry hme WHERE hme.value != null AND classof(hme.value).getName() = "com.sun.jmx.mbeanserver.NamedObject"

I start to get stuck: hash map entries are in arrays, owned by hash map instances, etc. and I'm not sure how to find my object in an array yet.

This is where the documentation really lets me down: it probably contains the information I need, but the various operators, etc, don't seem to do what I expect. Ugh. And the errors are very unclear (often simply "your query returned no results")