Hi Jevgeni,
Sorry this that we didn’t reply.
If you are just interested in using only our
snapshot API you can create your plugin and an application inside. We have such
a non-UI use-case which just parses a heap dump. You can hook any logic you
want in a similar way.
You can look at the <mat_root>\ParseHeapDump.bat
script (just assume Win for simplicity). It has inside:
"%_DIRNAME%\MemoryAnalyzer.exe"
-consoleLog -application org.eclipse.mat.api.parse %1 %2 %3 %4 %5 %6 %7 %8 %9
The application org.eclipse.mat.api.parse
is implemented in the class org.eclipse.mat.internal.apps.ParseSnapshotApp,
part of toe org.eclipse.mat.api plugin.
It’s rather simple and you’ll
find there how to open a snapshot using our API and get an instance of
ISnapshot. The logic/analysis afterwards you have already, as I understood.
The class is registered as an application
in the plugin.xml
<extension id="parse" point="org.eclipse.core.runtime.applications">
<application
cardinality="singleton-global"
thread="main"
visible="true">
<run class="org.eclipse.mat.internal.apps.ParseSnapshotApp" />
</application>
</extension>
I think that if you follow the same
approach you should be able to run your algorithms in a console mode. Let me
know if this hints help.
Regards,
Krum
From:
mat-dev-bounces@xxxxxxxxxxx [mailto:mat-dev-bounces@xxxxxxxxxxx] On Behalf Of Jevgeni Kabanov
Sent: Dienstag, 16. März 2010
13:31
To: Memory Analyzer Dev list
Subject: Re: [mat-dev] MAT API in
a command line tool
It's a specific tool. The background is that I want to collect some
information about class loaders and class loader leaks and for that want to
create a command line tool that people could download, run on a heap dump and
send the results back to me. I got the class loader leak detection all figured
out, but the tool I built on JHat was one big memory hole. So I want to use the
MAT parser and dominant tree analysis (btw awesome work, guys), but ran into
the whole OSGi thing.
I'm not sure if the analysis can be recorded as the XML (haven't taken
a look at it yet), but it wouldn't solve my problem as I don't want people to
install MAT. I actually managed to hack a version of MAT core without Eclipse
dependencies (basically replace all the factory lookups with implementations
and delete a bunch of code), but since the messaging depends heavily on Eclipse
I'm not 100% sure that it works (it does produce results, though). A better way
would probably be building a command line app that depends on your bundles, so
I'm looking for some pointers from the OSGi experts :)
On 16.03.2010, at 13:32, Tsvetkov, Krum wrote:
Do you 1) want to build a tool which just
does some specific check (without the GUI) and outputs the result somewhere? If
so, then the answer from Andrew should be sufficient.
Or are you 2) thinking of using the APIs
to work with heap dumps and offer command line interface for this? And if so,
do you think of implementing new queries/features, or you just want to expose
the existing ones via command line? At the very beginning the tool had a
command line interface (it was still before moving to Eclipe). And then it had
both GUI and command line. At some moment we dropped the command line. But most
of the queries are done in such a way, that the results which are returned are
not bound to the UI – they can be rendered in SWT and in HTML. Therefore
if you are happy with the existing functionality and want to expose it via
console, you can implement the part rendering the results to a console, and a
way to call something from a specific line (e.g. like a context menu). It
doesn’t exist.
I guess we can give better answers if we
understand better what you need.
I want to build a small command-line
analysis tool using the MAT APIs. I found the following page:
Does this mean that I should build my own
OSGi bundle/application that would depend on the headless parts of MAT and use
the API to analyze the heap? What would be a good place to start? Did anyone
have any experiences building command line tools with MAT that you could point
me to?
_______________________________________________
mat-dev mailing list
mat-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mat-dev