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

4

20

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(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())?

Lebron answered 29/6, 2011 at 9:13 Comment(0)
D
15

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.

Doersten answered 2/7, 2013 at 2:59 Comment(1)
Perfect! 3Q~~~~~Sitka
F
9

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)')
Fug answered 12/9, 2011 at 14:36 Comment(0)
L
1

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.

Lusty answered 25/10, 2018 at 7:16 Comment(0)
E
0

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

Elyseelysee answered 20/5, 2021 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.