Tools:
JVM Profiler - We have a plugin for it which could be installed in Eclipse.
MAT - Memory Analyzer Tool for analyzing the heap dump.
JVM monitor plugin for Eclipse
http://www.jvmmonitor.org/doc/index.html
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.tptp.platform.doc.user%2Fconcepts%2Fceproftl.xhtml
Note:
CW-Tomcat is running with java 32 bit and Eclipse also should be 32 bit.
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.tptp.platform.doc.user%2Fconcepts%2Fceproftl.xhtml
Note:
CW-Tomcat is running with java 32 bit and Eclipse also should be 32 bit.
Steps:
- Installed Eclipse helios 32 bit for windows
- Installed Liferay Plugin, EGit plugins for Eclipse
- Through Install New Software - http://releases.liferay.com/tools/ide/eclipse/helios/stable/
- Through Install New Software - http://download.eclipse.org/egit/updates-2.1
- Installed JVM Monitor plugin for Eclipse
- Through Eclipse Marketplace - Search JVM monitor and Click Install
- Through Preferences > Java > Monitor > Tools, Set JDK Root directory as C:\....\Softwares\jdk1.6.0_21
- Launch eclipse helios 32 bit from command prompt making Eclipse to use the same jdk that is set for JVM monitor, C:\...\Softwares\eclipse-jee-helios-SR2-win32\eclipse>eclipse -vm "C:\Mahesh\Softwares\jdk1.6.0_21\bin\javaw"
Monitoring JVM on remote host
To monitor JVM on remote host:
- Add the following configurations to JAVA_OPTS in ..../WAR/tomcat_folder/bin/setenv.sh
-Dcom.sun.management.jmxremote.port=9876 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
- Press the button Add JVM Connection on Remote Host on JVM Explorer to open New JVM Connection dialog.
- Enter the ip address of the remote server
- Enter the port: 9876
Note: Sometimes we may not be able to connect to remote server even after setting the above three JVM arguments. In that case, add the below argument as well.
-Djava.rmi.server.hostname= mention the host-name here
How to capture heap dump of JVM running in Remote host
Since 'JVM monitor' does not support viewing the Memory details when monitoring remote host, we may need to capture the heap dump for analyzing the heap memory usage. Below are the steps to capture the heap dump (Ref: http://www.jvmmonitor.org/doc/, under section "How can I enable the BCI mode of CPU profiler on remote host?")
- In the Eclipse JVM monitoring view, select the server to monitor. In the Properties screen, you will find Timeline, Threads, Memory, CPU, MBeans and Overview. Select 'Memory' tab.
- Click on the 'heap dump' symbol in the top-right corner to capture the heap dump.
- A dialog box will be shown with the path where the dump file should be saved in the remote server (eg. /home/liferay\32323432323.hprof). And it may not allow you to select the 'Transfer ....' checkbox or to click on OK button to initiate the dump. An info could be displayed saying that ' agent is not loaded'.
- Now follow the instructions given in http://www.jvmmonitor.org/doc/, under section "How can I enable the BCI mode of CPU profiler on remote host?"
- Copy the jvmmonitor-agent.jar from ~..\eclipse-jee-helios-SR2-win32\plugins\
org.jvmmonitor.core_3.8.1.201302030008\lib\jvmmonitor-agent.jar and drop it
into '/home/liferay' directory of Staging server (remote server) using WinSCP tool. - Add the following configurations to JAVA_OPTS in .../WAR/tomcat_folder/bin/setenv.sh
7. Done. Now we are ready to dump the file. The heap dump .hprof file will be saved at '/home/liferay/'
Suggestions from different sites:
It is definitely advisable to have on the -XX:+HeapDumpOnOutOfMemoryError setting. What is dumped is a binary .hprof file. The setting for the file location shuold be:
-XX:HeapDumpPath=/niku/logs/heapdump.hprof
Setup for this in setenv.sh
-XX:HeapDumpOnOutOfMemoryError –XX:HeapDumpPath=d:\heapDumps
-XX:HeapDumpOnOutOfMemoryError –XX:HeapDumpPath=d:\heapDumps
Some of the tools suggested in net are,
- MAT - Eclipse Memory Analyzer Tool - (Free) - http://www.eclipse.org/mat/downloads.php
- Visual VM - https://visualvm.dev.java.net/
- HAT - Java Heap Analysis Tool - http://docs.oracle.com/javase/6/docs/technotes/tools/share/jhat.html
- YourKit Java Profiler
I used MAT to analyze the heap dump (.hprof file).
MAT for Windows 32 bit was unable to open large dump files. (I tried with a .hprof file of ~2.2 GB). Also the max heap size of MAT-32 Bit was by default 1GB, which cannot be tweaked. As per suggestion from an Eclipse forum - installed MAT for Windows 64 bit which did the job and allowed to tweak the max heap size. Have configured the vm argument -Xmx to 3GB in MemoryAnalyzer.ini file. Then the heap dump loaded in MAT without errors.
No comments:
Post a Comment