Project

General

Profile

Actions

Profiling » History » Revision 16

« Previous | Revision 16/25 (diff) | Next »
Andreas Kohlbecker, 06/13/2013 01:50 PM


Java Profiling

YourKit Java Profiler

Profile the cdmserver (cdmlib-remote-webapp)

Preparation:

To enable profiling on remote server you just need to copy appropriate libyjpagent.so and, put it into LD_LIBRARY_PATH and add "-agentlib:yjpagent" to JVM parameters. Most probable you copied wrong library file, that's why server JVM doesn't start.

( For another way to specify the shared lib see http://www.yourkit.com/docs/java/help/agent.jsp )

For your convenience you can use the following script to start eclipse and set the LD_LIBRARY_PATH:

#!/bin/bash

###########################################
# Configuration
#

ECLIPSE_FOLDER=~/opt/eclipse-juno-SR2
YOURKIT_FOLDER=~/opt/yjp-9.0.8
OS_TYPE="linux-x86-64"

#
###########################################

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${YOURKIT_FOLDER}/bin/${OS_TYPE}
$ECLIPSE_FOLDER/eclipse -vmargs -Duser.name="a.kohlbecker"

Run cdmlib-remote-webapp in profiling mode:

Use the launch configuration cdmserver - profile which is distributed via the cdmlib source control.

creating a snapshot from within an application

IMPORTANT: Add yjp.jar from the yourkit lib folder to the classpath. Do not move it from it's original location!!!!.

Capture a snapshot by

com.yourkit.api.Controller controller = new Controller();
controller.forceGC(); // decreases snapshot size and makes finding memory leaks easier
controller.captureMemorySnapshot();

if you whant to do multiple snapshots you can also use the static method:

ProfilerController.memorySnapshot()

or create a method like the following in the class to be tested:

    private void captureMemorySnapshot() {
        if (controller == null) {
            try {
                controller = new Controller();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        try {
            controller.forceGC();
            logger.info("capturing snapshot ... ");
            logger.info("new snapshot file: " + controller.captureMemorySnapshot());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

TPTP

_Using TPTP is discouraged, we rather recommend using the YourKit Java Profiler

in Eclipse by using TPTP.

Updated by Andreas Kohlbecker almost 11 years ago · 16 revisions