Wednesday, June 30, 2010

How to setup remote profiling session with JProfiler

What does JProfiler do?
JProfiler is a tool to profile a JVM in runtime locally or remotely. Its profiling features are mainly in 2 parts which are CPU and memory.

In CPU part, it can shows all threads situation in JVM and its state(RUNNING,BLOCKING,WAITING,..) and also traces which part of instruction the thread currently runs. It can show object locking graph to identify a locking problem which is difficult to figure out by normal debugging.

In memory part, it collects and shows memory allocation stats, object counts and also traces the methods or classes which do most of memory allocation. Furthermore, it can shows what and when java garbage collector do with current memory consumption as a time-based graph.

How to setup?


  1. Download JProfiler and its evaluation key

  2. Install JProfiler in your computer.

  3. Copy JProfiler agent library to a target which you want to do remote profiling. JProfiler agent library is in [JProfiler path]/bin/

  4. Add an argument in JVM which you want to do profiling. (I use FreeBSD.)

    -agentpath:/usr/home/tmp/jprofiler6/bin/freebsd-x86/libjprofilerti.so=port=8849

    ** 8849 is a port for JProfiler client to communicate with its agent. You can change this

    if you have firewall, you may need to allow the port

    ipfw add 6000 allow tcp from any to me dst-port 8849 keep-state




    1. Open JProfiler client. -> Start center -> New session tab -> New session button -> select remote -> configure host and port of target jvm -> Start

    2. Start target JVM. it will pause and wait JProfiler to attach it.

    3. In JProfiler client, click Attach and OK

    It should be work now.
    Next time I may write about how to setup JProfiler with Eclipse to do local profiling. If you can’t wait, find it in JProfiler help.
    ** When the evaluation ends, the client still can open but it doesn’t work

    8 comments:

    1. .:: m3rLinEz ::.July 2, 2010 at 2:59 AM

      I can't wait! I'm helplessly reading the doc right now :P

      ReplyDelete
    2. Any idea how to setup remoteconnection using api,

      ie. offlinr profiling

      ReplyDelete
    3. Can you tell the argument in JVM for AIX 7 box to do profile my application for the following setting

      -agentpath:/usr/home/tmp/jprofiler6/bin/freebsd-x86/libjprofilerti.so=port=8849

      I am using JProfiler 6 as client in Windows 7 box.

      ReplyDelete
      Replies
      1. Do you mean there is no -agentpath option in JVM on AIX ? I don't know much about AIX but I think it's a standard option which JVM should have in every versions.

        BTW, I'm not sure if JProfiler provide agent library (libjprofilerti.so) for AIX.

        Delete
      2. Hi Teerapap, I found the following message in Integration Wizard in client Jprofiler 6, on choosing the 'Application on remote computer' option in Quick Start window.
        ---------------------------------------------------------------
        Integration type: [Generic application]
        Selected JVM: IBM 1.6.0 (jit compiler)
        Startup mode: Wait for a connection from the JProfiler GUI

        (1) Please insert

        -Xshareclasses:none "-agentpath:/apps/Softwares/JProfiler/Jprofiler 6/jprofiler6/bin/aix-ppc/libjprofilerti.so=port=8849"

        into the start command of your remote application right after the java command.

        A remote session named Remote application on 10.80.16.244 will be created that connects to a running instance of the remote application that is started with the modified start command.
        -------------------------------------------------------------
        Please tell me the which file need to be modified in remote machine. Is server.xml or change the JVM setup found in the WAS admin console screen.

        Thanks in Advance
        Abhijit

        Delete
      3. Continued with last reply, I am using JVM given by IBM WAS application server in my remote AIX box.

        Delete
      4. Those options are JVM options.

        I guess, it's JVM setup found in the WAS admin console screen.

        Delete
    4. This comment has been removed by the author.

      ReplyDelete