Not much useful reading material on SA other than the source code, which speaks for itself.<div>A lot of classes in SA mirror their counterparts in HotSpot's C++ code, so they're not that hard to understand.<br><div>
<br></div><div>The ones available are:</div><div>1. The HotSpot™ Serviceability Agent: An out-of-process high level debugger for a Java™ virtual machine</div><div><a href="http://static.usenix.org/event/jvm01/full_papers/russell/russell_html/">http://static.usenix.org/event/jvm01/full_papers/russell/russell_html/</a></div>
<div>This is an old paper, an overview of the SA.</div><div><br></div><div>2. Simple documentation on HotSpot Serviceability</div><div><a href="http://openjdk.java.net/groups/hotspot/docs/Serviceability.html">http://openjdk.java.net/groups/hotspot/docs/Serviceability.html</a></div>
<div><br></div><div>3. The docs in HotSpot's source code, located in hotspot/agent/doc</div><div><br></div><div>4. Poonam Bajaj did a presentation on the SA Plugin for VisualVM last year at JavaOne</div><div><a href="https://blogs.oracle.com/poonam/entry/javaone_presentation_on_sa_plugin">https://blogs.oracle.com/poonam/entry/javaone_presentation_on_sa_plugin</a></div>
<div><br></div><div>- Kris<br><br><div class="gmail_quote">On Mon, Oct 8, 2012 at 10:08 PM, Eric Caspole <span dir="ltr"><<a href="mailto:eric.caspole@amd.com" target="_blank">eric.caspole@amd.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is there a wiki or anything for Serviceability Agent? That looks useful.<br>
Thanks,<br>
Eric<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
On Oct 6, 2012, at 9:52 AM, Krystal Mok wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Azeem,<br>
<br>
(Sorry for the late reply. Just in case someone interested who's not familiar with Serviceability Agent...)<br>
<br>
The "universe" command in CLHSDB would fit your need perfectly.<br>
For example,<br>
<br>
$ java -cp $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB<br>
hsdb> attach 1234<br>
Attaching to process 1234, please wait...<br>
hsdb> universe<br>
ParallelScavengeHeap [ PSYoungGen [ eden =  [0x00000000fd560000,<u></u>0x00000000fedc00a0,<u></u>0x00000000ff4c0000] , from =  [0x00000000ff750000,<u></u>0x00000000ff9da020,<u></u>0x00000000ff9e0000] , to =  [0x00000000ff4c0000,<u></u>0x00000000ff4c0000,<u></u>0x00000000ff750000]  ] PSOldGen [  [0x00000000f8000000,<u></u>0x00000000f82eb078,<u></u>0x00000000fa9b0000]  ] PSPermGen [ [0x00000000f2e00000,<u></u>0x00000000f3970798,<u></u>0x00000000f42c0000]  ]  ]<br>

hsdb> quit<br>
$<br>
<br>
If you need to programmatically print this information, you could use sun.jvm.hotspot.gc_interface.<u></u>CollectedHeap.print().<br>
For example,<br>
<br>
import sun.jvm.hotspot.gc_interface.*<u></u>;<br>
import sun.jvm.hotspot.runtime.*;<br>
import sun.jvm.hotspot.tools.*;<br>
<br>
public class ShowUniverse extends Tool {<br>
    public void run() {<br>
        CollectedHeap heap = VM.getVM().getUniverse().heap(<u></u>);<br>
        heap.print();<br>
    }<br>
<br>
    public static void main(String[] args) {<br>
        ShowUniverse tool = new ShowUniverse();<br>
        tool.start(args);<br>
        tool.stop();<br>
    }<br>
}<br>
<br>
And used as:<br>
<br>
$ javac -classpath $JAVA_HOME/lib/sa-jdi.jar ShowUniverse.java<br>
$ java -cp .:$JAVA_HOME/lib/sa-jdi.jar ShowUniverse 1234<br>
Attaching to process ID 1234, please wait...<br>
Debugger attached successfully.<br>
Server compiler detected.<br>
JVM version is 22.0-b10<br>
ParallelScavengeHeap [ PSYoungGen [ eden =  [0x00000000fd560000,<u></u>0x00000000fedc00a0,<u></u>0x00000000ff4c0000] , from =  [0x00000000ff750000,<u></u>0x00000000ff9da020,<u></u>0x00000000ff9e0000] , to =  [0x00000000ff4c0000,<u></u>0x00000000ff4c0000,<u></u>0x00000000ff750000]  ] PSOldGen [  [0x00000000f8000000,<u></u>0x00000000f82eb078,<u></u>0x00000000fa9b0000]  ] PSPermGen [ [0x00000000f2e00000,<u></u>0x00000000f3970798,<u></u>0x00000000f42c0000]  ]  ]<br>

<br>
$<br>
<br>
If you need to access the individual virtual addresses programmatically, just look at the implementations of CollectedHeap.printOn(<u></u>PrintStream tty) in GenCollectedHeap/<u></u>ParallelScavengeHeap/<u></u>G1CollectedHeap for example.<br>

<br>
Hope that helps,<br>
Kris<br>
<br>
On Mon, Oct 1, 2012 at 9:10 PM, Azeem Jiva <<a href="mailto:azeem.jiva@oracle.com" target="_blank">azeem.jiva@oracle.com</a>> wrote:<br>
Krystal,<br>
  That would work as well, I just need some way of getting the data while the JVM is running.<br>
<br>
<br>
On 09/30/2012 08:58 PM, Krystal Mok wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Azeem,<br>
<br>
It'd be easy to get with an SA agent instead of a JVMTI agent. Would that do for you?<br>
<br>
- Kris<br>
<br>
On Sat, Sep 29, 2012 at 2:08 AM, Azeem Jiva <<a href="mailto:azeem.jiva@oracle.com" target="_blank">azeem.jiva@oracle.com</a>> wrote:<br>
Is there a way to get at the virtual addresses for the heap from a JVMTI agent?  The data is clearly available as PrintGCDetails dumps the information at the end of the run.<br>
<br>
-- <br>
Azeem Jiva<br>
@javawithjiva<br>
<br>
<br>
</blockquote>
<br>
-- Azeem Jiva @javawithjiva<br>
<br>
</blockquote>
<br>
<br>
</div></div></blockquote></div><br></div></div>