Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analyzing heap dump, Map#size() is not a function?

Getting this weird error:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: size is not a function, it is null. (#1)

While analyzing a heap dump and running this OQL query on VisualVM:

select { map: x } 
from java.util.concurrent.ConcurrentHashMap x 
where x.size() < 10

The problem lies on the where clause, somehow it's not working though Map obviously has a size method.

like image 965
Pablo Fernandez Avatar asked Nov 08 '12 19:11

Pablo Fernandez


1 Answers

@ruakh's answer is preety good, except one little thing. A segment sometimes could be null, which messes up sum(x.segments, 'it.count'). Replace it with

sum(x.segments, 'it != null ? it.count : 0')

and it will work fine. Tested upon my word.

like image 78
Nándor Krácser Avatar answered Sep 29 '22 09:09

Nándor Krácser