Compute sizes of classes loaded in perm gen

Sergei Mihhailov rsi2m at yandex.ru
Thu Mar 20 08:17:41 UTC 2014


Thank you for response, Kris!


The only goal I'm trying to achieve is to  to compute sizes of classes 
loaded in perm gen.

As I've understood, this is possible only by using Serviceability Agent?


- Sergei
On 20.03.2014 00:12, Krystal Mok wrote:
> Hi Sergei,
>
> "jmap -permstat", or "PermStat" itself is an utility based on the 
> Serviceability Agent.
>
> For your reference, I've written other utilities based on SA, some of 
> them listed here: http://rednaxelafx.iteye.com/blog/1814429
>
> The easiest way to write your own custom SA-based tool is to inherit 
> from the sun.jvm.hotspot.tools.Tool class and implement your logic in 
> a "public void run()" method.
>
> Do please keep in mind that SA is a out-of-process debugger, and it 
> works very differently from Java agents or JVMTI agents, in that the 
> latter two runs in-process.
>
> A question to you is: what are you really trying to achieve? Whether 
> or not using SA is applicable for you very much depends on what you're 
> trying to do.
>
> I don't know of any JVMTI functions that could give you information on 
> the InstanceKlass. The heap iterations functions don't expose 
> information on VM metadata, as can be seen here:
> http://hg.openjdk.java.net/jdk7u/jdk7u/hotspot/file/tip/src/share/vm/services/serviceUtil.hpp#l38
> (In JDK 8, there is no PermGen, and the VM metadata is moved out to 
> Metaspace which is in native memory, and JVMTI IterateThroughHeap() 
> doesn't even iterate over that space.)
>
> - Kris
>
>
>
> On Wed, Mar 19, 2014 at 1:22 PM, Sergei Mihhailov <rsi2m at yandex.com 
> <mailto:rsi2m at yandex.com>> wrote:
>
>     Thank you for response, Kris!
>
>
>     I'm writing both "Java agent" and JVMTI agent.
>
>     Are you suggesting that I should write Serviceability Agent
>     instead? If yes, then could you please pinpoint me into the right
>     direction? Because it wasn't clear to me how can I write my own
>     custom Serviceability Agent.
>
>     By the way, is it possible to compute sizes of classes loaded in
>     perm gen only by using "Java Agent" and JVMTI agent?
>
>
>     - Sergei
>     19.03.2014, 17:39, "Krystal Mok" <rednaxelafx at gmail.com
>     <mailto:rednaxelafx at gmail.com>>:
>>     Hi Sergei,
>>     Are you using PermStat in the context of Serviceability Agent? In
>>     other words, is the agent you're writing a "Serviceability
>>     Agent", or something else, like a "Java agent" as in
>>     java.lang.instrument, or a "JVMTI agent"? SA uses different means
>>     to connect to the target VM from the other types of agents, so
>>     you can't mix them up.
>>     - Kris
>>
>>     On Wednesday, March 19, 2014, Sergei Mihhailov <rsi2m at yandex.ru
>>     <mailto:rsi2m at yandex.ru>> wrote:
>>
>>         Greetings,
>>
>>         I'm writing special purpose java agent to compute sizes of
>>         classes loaded in perm gen. Basically reimplementing some
>>         functionality of "jmap -permstat". But in order to do that, I
>>         need to get instances of InstanceKlass for all loaded classes.
>>
>>         I've looked up PermStat source code, and tried to use it
>>         internally in my agent using its start() method. This attempt
>>         failed : "sun.jvm.hotspot.debugger.DebuggerException: Can't
>>         attach to the process"
>>
>>         Is it somehow possible to compute sizes of classes loaded in
>>         perm gen?
>>
>>
>>         Thanks,
>>         Sergei
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20140320/6236d9df/attachment.html>


More information about the serviceability-dev mailing list