11

I am trying to programmatically analyze an hprof file. Using the hprof-conv tool in the android-sdk I generated a bunch of com.your.package.index files.

How do I programmatically parse these .index files?

I want run some custom analysis on the dominator tree, which is easy to do through MAT (Eclipse's Memory Analyser) manually but want to do it in an automated way.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Abhishek
  • 1,749
  • 9
  • 27
  • 39
  • 3
    For those encountering this question, here is the OP's earlier question as background: http://stackoverflow.com/questions/15977723/analyse-a-hprof-memory-dump-file-from-command-line-programmically – CommonsWare Apr 12 '13 at 20:29
  • Is hacking the [Mat plugin source](http://dev.eclipse.org/svnroot/tools/org.eclipse.mat/trunk/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/) at option for you? I looked through the source and didn't see any "Dominator tree" though? – hack_on May 09 '13 at 09:53
  • @hack_on [I'm not sure you looked hard enough](http://dev.eclipse.org/svnroot/tools/org.eclipse.mat/trunk/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/DominatorTree.java). That doesn't look as terrible to adapt as it could. The [SnapshotImpl](http://dev.eclipse.org/svnroot/tools/org.eclipse.mat/trunk/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImpl.java) given as input looks like where the file's read in. – blahdiblah Nov 15 '13 at 03:55

1 Answers1

2

You can try using the MAT from command lines and generate custom reports (dominator tree). In this you can either filter using the XML that can be used to generate the report or parse the report via a external code.

Refer: http://www.eclipse.org/forums/index.php/t/489594/

The above link should guide you through this task...

Karthik S
  • 91
  • 1
  • 10
  • 1
    please mention that how it will analyse automatically using this tool. – Hamad Nov 20 '13 at 06:15
  • 1
    There are several ways of doing this, you can watch the hprof directory using file monitors in the java 7 NIO and trigger the MAT using the above comment. For folder monitoring code look: http://javapapers.com/core-java/monitor-a-folder-using-java/ – Karthik S Nov 20 '13 at 09:55