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

BenMorel
  • 34,448
  • 50
  • 182
  • 322
uuidcode
  • 3,790
  • 3
  • 25
  • 30

4 Answers4

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.

Liam Mooney
  • 151
  • 1
  • 2
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)')
Johan Kaving
  • 4,870
  • 1
  • 27
  • 21
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.

Liu Tom
  • 397
  • 2
  • 9
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