Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

OQL query to find empty maps

castorpJan 26 2012
Hello,

I'm trying to find instances of a Map inside a heapdump using VisualVM's "OQL Console".

But I can't figure out how to access the size (or count) property of a map.

What I tried was the following:
select m from java.util.concurrent.ConcurrentHashMap m where m.count == 0
But that didn't return anythong (although I know that there are empty maps in the heap by looking at the instances itself)

Then I found another example which used some kind of casting to ensure that m.count would be treated as a number:
select m from java.util.concurrent.ConcurrentHashMap m where m.count * 1 == 0
That seemed to returned instances, but when I tried to find the non-empty ones using
select m from java.util.concurrent.ConcurrentHashMap m where m.count * 1 > 0
I didn't return anything, and I know (again from looking at the instances) that there are non-empty maps in there.

I also tried replacing m.count with m.size in all examples, but still no go.

I'm sure I'm missing something obvious with the OQL syntax, but what?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2012
Added on Jan 26 2012
0 comments
1,846 views