Getting the Heap virtual addresses?

Eric Caspole eric.caspole at amd.com
Mon Oct 8 14:08:14 UTC 2012


Is there a wiki or anything for Serviceability Agent? That looks useful.
Thanks,
Eric



On Oct 6, 2012, at 9:52 AM, Krystal Mok wrote:

> Hi Azeem,
>
> (Sorry for the late reply. Just in case someone interested who's  
> not familiar with Serviceability Agent...)
>
> The "universe" command in CLHSDB would fit your need perfectly.
> For example,
>
> $ java -cp $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB
> hsdb> attach 1234
> Attaching to process 1234, please wait...
> hsdb> universe
> ParallelScavengeHeap [ PSYoungGen [ eden =   
> [0x00000000fd560000,0x00000000fedc00a0,0x00000000ff4c0000] , from  
> =  [0x00000000ff750000,0x00000000ff9da020,0x00000000ff9e0000] , to  
> =  [0x00000000ff4c0000,0x00000000ff4c0000,0x00000000ff750000]  ]  
> PSOldGen  
> [  [0x00000000f8000000,0x00000000f82eb078,0x00000000fa9b0000]  ]  
> PSPermGen  
> [ [0x00000000f2e00000,0x00000000f3970798,0x00000000f42c0000]  ]  ]
> hsdb> quit
> $
>
> If you need to programmatically print this information, you could  
> use sun.jvm.hotspot.gc_interface.CollectedHeap.print().
> For example,
>
> import sun.jvm.hotspot.gc_interface.*;
> import sun.jvm.hotspot.runtime.*;
> import sun.jvm.hotspot.tools.*;
>
> public class ShowUniverse extends Tool {
>     public void run() {
>         CollectedHeap heap = VM.getVM().getUniverse().heap();
>         heap.print();
>     }
>
>     public static void main(String[] args) {
>         ShowUniverse tool = new ShowUniverse();
>         tool.start(args);
>         tool.stop();
>     }
> }
>
> And used as:
>
> $ javac -classpath $JAVA_HOME/lib/sa-jdi.jar ShowUniverse.java
> $ java -cp .:$JAVA_HOME/lib/sa-jdi.jar ShowUniverse 1234
> Attaching to process ID 1234, please wait...
> Debugger attached successfully.
> Server compiler detected.
> JVM version is 22.0-b10
> ParallelScavengeHeap [ PSYoungGen [ eden =   
> [0x00000000fd560000,0x00000000fedc00a0,0x00000000ff4c0000] , from  
> =  [0x00000000ff750000,0x00000000ff9da020,0x00000000ff9e0000] , to  
> =  [0x00000000ff4c0000,0x00000000ff4c0000,0x00000000ff750000]  ]  
> PSOldGen  
> [  [0x00000000f8000000,0x00000000f82eb078,0x00000000fa9b0000]  ]  
> PSPermGen  
> [ [0x00000000f2e00000,0x00000000f3970798,0x00000000f42c0000]  ]  ]
>
> $
>
> If you need to access the individual virtual addresses  
> programmatically, just look at the implementations of  
> CollectedHeap.printOn(PrintStream tty) in GenCollectedHeap/ 
> ParallelScavengeHeap/G1CollectedHeap for example.
>
> Hope that helps,
> Kris
>
> On Mon, Oct 1, 2012 at 9:10 PM, Azeem Jiva <azeem.jiva at oracle.com>  
> wrote:
> Krystal,
>   That would work as well, I just need some way of getting the data  
> while the JVM is running.
>
>
> On 09/30/2012 08:58 PM, Krystal Mok wrote:
>> Hi Azeem,
>>
>> It'd be easy to get with an SA agent instead of a JVMTI agent.  
>> Would that do for you?
>>
>> - Kris
>>
>> On Sat, Sep 29, 2012 at 2:08 AM, Azeem Jiva  
>> <azeem.jiva at oracle.com> wrote:
>> 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.
>>
>> -- 
>> Azeem Jiva
>> @javawithjiva
>>
>>
>
> -- Azeem Jiva @javawithjiva
>





More information about the hotspot-gc-dev mailing list