is there any way to print top used N classes on the current java application programmatically?
sample output: N=10
num #instances #bytes class name
--------------------------------------
1: 23 4723136 [I
2: 19 4718928 [J
3: 18 4718880 [D
4: 73925 1774200 java.lang.String
5: 208 1226400 [C
6: 28 1205064 [B
7: 18 1179936 [F
8: 68 297040 [Ljava.lang.String;
9: 332 14136 [Ljava.lang.Object;
10: 32 10240 <objArrayKlassKlass>
You could kick off jmap
as part of your java wrapper script and run it continuously in a loop:
For example, if you are on Unix, you could do something like:
java MyMainClass ... &
pid=$!
while [ ! -z $pid ]
do
jmap -histo $pid | head -13
sleep 60
#check pid
kill -0 $pid > /dev/null 2>&1
if [ $? -ne 0 ]
then
pid=""
fi
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With