Export to hprof format?

Questions about YourKit Java Profiler
Post Reply
haridsv
Posts: 11
Joined: Thu May 09, 2013 6:57 am

Export to hprof format?

Post by haridsv »

Is there anyway to export/convert the memory snapshot into hprof format so that I can open it in Eclipse MAT tool? I am currently looking at a memory snapshot and have the need to run some OQL queries. Thank you!
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Export to hprof format?

Post by Anton Katilin »

There is no way to convert, but you can capture snapshot in HPROF format:
http://www.yourkit.com/docs/java/help/h ... pshots.jsp

[EDIT: The converter was added in v2014.]
haridsv
Posts: 11
Joined: Thu May 09, 2013 6:57 am

Re: Export to hprof format?

Post by haridsv »

Thanks Antony for the response, I am aware of that option. Could this be added as a feature request?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Export to hprof format?

Post by Anton Katilin »

Yes, we can add a request, but I cannot promise it will be of a high priority.
have the need to run some OQL queries.
What are you looking for in particular? Could you please provide detail.

Perhaps the profiler is already able to provide the requested information but you didn't notice corresponding feature, or we should consider adding a new feature if we find it useful to other users too.
haridsv
Posts: 11
Joined: Thu May 09, 2013 6:57 am

Re: Export to hprof format?

Post by haridsv »

Right now, I just want to get all the String's that are referred by certain type and export them to a file, something like this:

select toString(o.rawObject) from a.b.c o

where o.rawObject is a String. Is this possible in YourKit?

In general, OQL is quite powerful, so I can see having other requirements in the future that may not be possible within YourKit. Also, I find that the YourKit interface is quite limiting (e.g., the object explorer on large arrays).
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Export to hprof format?

Post by Anton Katilin »

YourKit has the object set description feature:

http://www.yourkit.com/docs/java/help/language.jsp

It seems this one is what you need:

Code: Select all

  <reachable-objects>
    <from>
      <objects class="a.b.c"/>
    </from>

    <object-filter>
      <objects class="java.lang.String"/>
    </object-filter>

    <field-filter>
      <class name="a.b.c">
        <allowed field="rawObject"/>
      </class>
    </field-filter>
  </reachable-objects>
haridsv
Posts: 11
Joined: Thu May 09, 2013 6:57 am

Re: Export to hprof format?

Post by haridsv »

Thanks, but where do I stick in the custom XML? When I open Settings -> Sets of Objects, I don't see an option to create a new set.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Export to hprof format?

Post by Anton Katilin »

Hm, it's gone. Must be a bug. We'll fix it ASAP.

As a workaround please click one of existing sets and replace the description with the xml I've provided.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Export to hprof format?

Post by Anton Katilin »

please click
Double click.
haridsv
Posts: 11
Joined: Thu May 09, 2013 6:57 am

Re: Export to hprof format?

Post by haridsv »

Worked for this specific use case, but it is clunky! Besides, OQL has many features such as the ability to call methods, select items in an array and use subselects, so you should either add this feature yourself, or allow exporting to hprof (after all, it is a JVM standard, and there could be other reasons why a user would want to do this).
haridsv
Posts: 11
Joined: Thu May 09, 2013 6:57 am

Re: Export to hprof format?

Post by haridsv »

Thank you!
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Export to hprof format?

Post by Anton Katilin »

The converter was added in v2014.
Post Reply