How to do memory profiling on remote java web application
Solution 1
you have VisualGC, it's not very advanced but you can see the memory usage of your application (garbage,old, perm etc...)
http://java.sun.com/performance/jvmstat/visualgc.html
to resume : you launch a daemon monitoring on the remote machine (http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstatd.html, see the security parapraph)
JAVA_HOME/bin/jstatd -J-Djava.security.policy=jstatd.all.policy
with a file here called jstatd.all.policy containing :
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
on the remote machine you got the pid of your application to debug with the jps tool :
http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jps.html#jps
finally on your local machine you launch the visualgc :
visualgc the_pid@remote_machine_address
Solution 2
I usually use YourKit which is an excellent application (license needed).
In your webservers startup/shutdown script (catalina.sh for tomcat) put in:
JAVA_OPTS="-Djava.awt.headless=true -agentlib:yjpagent -Xrunyjpagent:sessionname=Tomcat"
You'll need YourKit already downloaded and added to your library path (I do this in catalina.sh as well):
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/yourkit/yjp-6.0.16/bin/linux-x86-32
You can then launch the YourKit client on your local desktop and remotely connect.
Solution 3
You can change to VM params of your Java application to allow remote profiling
something like -agentlib:jprofilerti=port=25000
General explanation of JProfiler.
Examples:
Solution 4
Profile your application using Jprofiler. Below are the steps to configure your Tomcat with Jprofiler.
In Linux machine open
.bash_profile
file from/root
directory.
Enter jprofiller location (using below command export) in.bash_profile file export LD_LIBRARY_PATH=/dsvol/jprofiler6/bin/linux-x86
Go Tomcat installation directory. Open
catalena.sh
file frombin
folder.
Enter the below details incatelana.sh
file (only red color information and black color you can find by default in catalena.sh file).export JPROFILER_HOME JAVA_OPTS="-Xms768m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF8 -agentpath:/opt/Performance/jprofiler7/bin/linux-x86/libjprofilerti.so=port=8849 $CATALINA_OPTS"
Start the server from bin folder by executing the
starup.sh
command
Nick Long
Updated on June 04, 2022Comments
-
Nick Long almost 2 years
I know we can use tools like JProfiler etc. Is there any tutorial on how to configure it to display the memory usage just by remote monitoring?
Any idea?
-
Himanshu over 11 yearsThis is link only. Please add more information on your answer
-
kjb almost 11 yearsVisualVM does not support memory profiling on remote machines, only CPU profiling