To find JVM memory usage in shell console


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To find JVM memory usage in shell console
# 1  
Old 01-18-2013
To find JVM memory usage in shell console

i need to find memory usage by JVM in shell prompt,

i tried with
Code:
pidVal=$( ps -ef | grep "/opt/bea2/jrockit/bin/java -jrockit" | grep -v grep | awk -F' ' '{print $2}' | tr "\n" "," | cut -d ',' -f1 )
 
top -b -n 1 | grep $pidVal

this will just give cpu usage and ram... How do i find the actual memory usage of JVM,

from Server monitoring console (Hyperic)( HQ health) it will show consumption in real time. i need to find the same at shell prompt. Any help wil be deeply appreciated.
# 2  
Old 01-18-2013
Have a look at jstat.
# 3  
Old 01-18-2013
What OS: Linux, Solaris, ... other?

On Linux this will give you what the OS sees as resident for all java processes (use -ovsz for virtual):
Code:
ps -orss= -p$(/sbin/pidof java)

With jrockit you could also use jrcmd <pid> print_memusage for more detailed info.
# 4  
Old 01-18-2013
i tried the command (i am using linux)

below which one is memory allocated and memory free or used?
Code:
# ps -orss= -p $(/sbin/pidof java)
597712
105300
47364
143556
1441024
4416636
1080604
3922112
132776
118644

Code:
]# jrcmd $pidVal print_memusage
9457:
Total mapped                  2864288KB           (reserved=1325008KB)
-              Java heap      1048576KB           (reserved=0KB)
-              GC tables        35084KB
-          Thread stacks        25204KB           (#threads=56)
-          Compiled code      1048576KB           (used=15421KB)
-               Internal         1864KB
-                     OS       236040KB
-                  Other       327120KB
-            Classblocks         7936KB           (malloced=7755KB #20432)
-        Java class data       132864KB           (malloced=132259KB #92498 in 20432 classes)
- Native memory tracking         1024KB           (malloced=125KB #10)



in the HQ monitor console its showing as

Code:
JVM Memory
% Used:31Free:5.3 GBTotal Allocated:7.7 GBMax Allocation:7.7 GB

so its not tallying up :-(
# 5  
Old 01-18-2013
It seems that you have 10 java processes. If HQ monitor is reporting the memory usage for a single JVM, you could run:
Code:
ps -opid,rss,vsz -p $(/sbin/pidof java)

... and there should be a pid, with VSZ of about 7.7. You should compare its RSS to what the HQ monitor shows.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Find memory usage for a process

I have multiple oracle databases on one server. All the database are running from the same user i.e. oraent. The process for each database can be distinguished by the ps -ef command Eg : ps -ef | grep oraentThe Output : oraent 5361 1 0 20:58:05 ? 0:00 oracledb1... (11 Replies)
Discussion started by: yashreads
11 Replies

2. UNIX for Dummies Questions & Answers

Default JVM Memory

Hi , Whenever I am starting JVM it is getting started with Xms as 256MB, which is 1/64 of the Memory available and by default this should happen. But I want to change and start the every JVM with 128MB. Is there any way to do or I have to manually specify Xms tag while starting JVM. Thanks (1 Reply)
Discussion started by: Raj999
1 Replies

3. UNIX for Dummies Questions & Answers

JVM Memory

Hi all, I am starting a JVM in unix and when I use ps command on the pid of process starting JVM the output is something like this :- java -Xms32M -Xmx64M -Xmx128M I need to know what would be the value of Xmx in this case. And how to check that this value be picked while starting JVM... (3 Replies)
Discussion started by: Raj999
3 Replies

4. Solaris

How to find out the memory usage in Solaris?

Hi All, In one of the solaris box aslert got triggered as ... (Used_Real_Mem_Pct=93.0 Used_Swap_Space_Pct=75.0 )] when i see the usage by vmstat and sar i am not able to relate the alert with the free memory and swap memory please help to understand the vmstat output as below.. kthr ... (4 Replies)
Discussion started by: Riverstone
4 Replies

5. UNIX for Advanced & Expert Users

JVM Memory used on AIX

Hello, i need just a Unix command line (AIX 6) that gives me the memory/CPU used by a WebSphere JVM from it's PID such as ps -ef | grep 'jvm name'. I know jstat -gc PID but it didn't work Could you help me please Thanks Christian (1 Reply)
Discussion started by: steiner
1 Replies

6. UNIX for Advanced & Expert Users

Find memory usage along with time

Hi Guys, I have a script. It calls an executable inside (programmed in C). I will have to find the execution time of that script and amount of memory consumed by that process as well. #!/bin/sh echo "Script starting" echo "executable staring" executable parm1 parm2 parm3 echo... (4 Replies)
Discussion started by: PikK45
4 Replies

7. Solaris

jvm memory settings

When i changed jvm memory settings from 3048 to 3548, appsserver could not start. if no change , it was normal. How do we change .otherwise i had a out of swap space error appeared after 3hrs period when do the monitoring of java application. (1 Reply)
Discussion started by: vijill
1 Replies

8. UNIX for Advanced & Expert Users

How to find out memory & cpu usage of a process

Hi, By using time command we can determine the execution time of a process or command. bash-2.04$ time ls -l total 0 -rw-r--r-- 1 admin tac 0 Oct 6 04:46 file1 -rw-r--r-- 1 admin tac 0 Oct 6 04:46 file2 real 0m0.002s user 0m0.000s sys 0m0.001s... (5 Replies)
Discussion started by: learn more
5 Replies

9. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

10. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies
Login or Register to Ask a Question