开发者

how to sum @retainedHeapSize with oql in the Eclipse Memory Analyzer Tool

Have you used MAT(Memory Analyzer Tool) from eclipse. it's really cool.(1.5G heap dump file kill jhat, ibm's heap dump analyzer with OOME). MAT is alive and fast and beautiful and powerful.

I wonder how much the ehcahce key's memory size is, so write oql below.

SELECT c.key.@retainedHeapSize 
FROM net.sf.ehcache.store.compound.HashEntry c 

Unfortunately, the group function like sum(), max(), min() does't exist. I export total result row开发者_如何学Go(about 60,000) to excel file and sum in the excel sheet.

Do you have the tip or hidden(?) function/feature about using group function(like sum())?


You can generate a Histogram from the OQL results - select the "Show as Histogram" icon. From this histogram you can calculate the retained size using the "Calculate Precise Retained Set" icon.


As far as I can tell from the Memory Analyzer documentation there are no aggregation functions in it's OQL.

However, in VisualVm (included with the JDK since 1.6 and downloadable as a standalone application) you can do it like this:

select sum(heap.objects('net.sf.ehcache.store.compound.HashEntry'), 'rsizeof(it)')

or, if you want the shallow size instead of the retained size - change the "rsizeof" to "sizeof":

select sum(heap.objects('net.sf.ehcache.store.compound.HashEntry'), 'sizeof(it)')


It is seems that there is no way to do it in the MAT or by the OQL

However you can do it by the other way.

after you execute your query, you can export the result to a cvs file. then you can get the result by the excel sum tool.


If you prefer MAT to Visual VM and not insist on OQL you can also use it's calcite plugin (https://github.com/vlsi/mat-calcite-plugin).

An example for the sum is:

SELECT sum(retainedSize(n.this['key']))
FROM "java.util.HashMap$Node" n

You can compare it's capabilities with oql here: https://wiki.eclipse.org/MemoryAnalyzer/OQL#OQL_.28Memory_Analyzer.29_versus_SQL_.28MAT.2FCalcite.29

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜