<%@ taglib uri="webwork" prefix="webwork" %> <%@ taglib uri="sitemesh-page" prefix="page" %> <%@ page import="com.yourkit.api.Controller" %> <%@ page import="com.yourkit.api.ProfilingModes" %> <%! private String stopMemoryRecording(Controller controller) { try { controller.stopAllocationRecording(); return "Successfully stoped allocation recording"; } catch (Exception e) { // Show error to the screen e.printStackTrace(); throw new RuntimeException("Unable to stop allocation recording, cause: " + e.getMessage()); } } private String stopCPURecording(Controller controller) { try { controller.stopCPUProfiling(); return "Successfully stoped CPU times measuring"; } catch (Exception e) { // Show error to the screen e.printStackTrace(); throw new RuntimeException("Unable to stop CPU times measuring, cause: " + e.getMessage()); } } private String dumpMemoryInfo(Controller controller) { try { String filePath = controller.captureMemorySnapshot(); return "Successfully generated a memory snapshot to: " + filePath + " please attach this file to a support request."; } catch (Exception e) { // Show error to the screen e.printStackTrace(); throw new RuntimeException("Unable to create a yourkit memory snapshot, cause: " + e.getMessage()); } } private String dumpCPUInfo(Controller controller) { try { String filePath = controller.captureCPUSnapshot(false); return "Successfully generated a cpu snapshot to: " + filePath + " please attach this file to a support request."; } catch (Exception e) { // Show error to the screen e.printStackTrace(); throw new RuntimeException("Unable to create a yourkit cpu snapshot, cause: " + e.getMessage()); } } private String startCPURecording(Controller controller) { try { controller.startCPUProfiling(ProfilingModes.CPU_SAMPLING | ProfilingModes.CPU_J2EE, null); return "Successfully started CPU times measuring"; } catch (Exception e) { // Show error to the screen e.printStackTrace(); throw new RuntimeException("Unable to start yourkit cpu recording, cause: " + e.getMessage()); } } private String startMemoryRecording(Controller controller) { try { controller.startAllocationRecording(ProfilingModes.ALLOCATION_RECORDING_ADAPTIVE); return "Successfully started allocation recording"; } catch (Exception e) { // Show an error on the screen e.printStackTrace(); return "Unable to start yourkit memory recording, cause: " + e.getMessage(); } } %> <% String error = null; String message = null; try { %> <% String action = request.getParameter("action"); Controller controller = new Controller(); if ("StartCPURecording".equals(action)) { message = startCPURecording(controller); } else if ("StartMemoryRecording".equals(action)) { message = startMemoryRecording(controller); } else if ("DumpCPUInfo".equals(action)) { message = dumpCPUInfo(controller); } else if ("DumpMemoryInfo".equals(action)) { message = dumpMemoryInfo(controller); } else if ("StopCPURecording".equals(action)) { message = stopCPURecording(controller); } else if ("StopMemoryRecording".equals(action)) { message = stopMemoryRecording(controller); } } catch (RuntimeException re) { re.printStackTrace(); error = re.getMessage(); } catch (Throwable t) { t.printStackTrace(); error = "An unknown error occurred, caused by: " + t.getMessage(); } %> Manage YourKit CPU/Memory Profiling 100% This page lets you generate YourKit CPU/Memory snapshots. You need to have enabled YourKit as specified in the instructions ">here. The snapshots will be saved to the directory you specified via the 'dir' property provided to the YourKit agent JVM argument.
Memory Profiling CPU Profiling
You may want to run the YourKit Memory profiler if your application is getting out of memory errors.

<%--Start--%> <%--Stop--%> Take a Memory Snapshot

You may want to run the YourKit CPU profiler if you feel you are experiencing performance bottlenecks. You must start CPU recording before you try to take a CPU snapshot. Taking a snapshot will automatically stop CPU recording.

Start CPU Recording | Stop CPU Recording | Take a CPU Snapshot (stops profiler)

<% if (error != null) { %>

: <%=error%>

<% } %> <% if (message != null) { %>

<%=message%>

<% } %>