Jprofiler Detailed Usage Introduction (JVM Object memory thread monitoring tool) "Go"

Source: Internet
Author: User
Tags jprofiler

First, install the Jprofiler

Download 5.1.2 from http://www.ej-technologies.com/and request a trial serial number

Second, the main function of the introduction

1. Memory Profiler

The memory view portion of Jprofiler can provide a dynamic memory usage update view and a view that displays information about memory allocation status. All views have several aggregation layers and are able to display existing objects and objects that are garbage collected.

    • All objects
      Displays a package of classes or all objects on the status statistics and sizing information heap. You can mark the current value and display the difference value.
    • Recording object Record objects
      Displays the package for the class or all logged objects. You can mark the current value and display the difference value.
    • Assigning access trees Allocation Call Tree
      A Java EE component that displays a request tree or method, class, package, or annotated allocation information for a selected class.
    • Distribution hotspot Allocation Hot spots
      Displays a list of methods, classes, packages, or EE components that are assigned the selected class. You can label the current value and display the difference value. For each hotspot, it can be displayed in the trace log tree.

2. Heap Traversal Heap Walker

In Jprofiler's heap Walker, you can take a snapshot of the state of the heap and find objects of interest by selecting the steps. There are five views of the heap walker:

    • Class Classes
      Displays all classes and their instances.
    • Assigning allocations
      Displays the allocation tree and the distribution hotspot for all record objects.
    • Index References
      Provides the ability to display the index graph for a single object and a path to the garbage collection root. It also provides the ability to merge input and output views.
    • Data
      Displays instance and class data for a single object.
    • Time
      Displays a histogram of the resolution time for the logged object.

3. CPU Profiling CPU Profiler

Jprofiler provides different ways to record an access tree to optimize performance and detail. Thread or thread groups and thread conditions can be selected by all views. All views can be clustered onto different tiers, such as methods, classes, packages, or Java EE components. The CPU Views section includes:

    • Access Tree Call Trees
      Displays an accumulated top-down tree that contains all the access queues that have been logged in the JVM. Both JDBC,JMS and Jndi service requests are commented on in the request tree. The request tree can be split according to the different needs of the servlet and JSP for the URL.
    • Hot spots
      Displays a list of the methods that consumed the most time. A backtracking tree can be displayed for each hotspot. The hotspot can be evaluated according to the method request, JDBC,JMS and Jndi service requests, and by URL requests.
    • Access Graph Call Graph
      Displays a diagram of the access queue starting from the selected method, class, package, or Java EE component.

4. Threading Profiling Thread Profiler

For threading profiling, Jprofiler provides the following views:

    • Threading History Thread
      Displays an activity schedule that is associated with thread activity and thread state.
    • Threading Monitoring Thread Monitor
      Displays a list of all active threads and their current activity status.
    • Deadlock Detection Chart Deadlock Detection
      Displays a deadlock chart that contains all of the deadlocks in the JVM.
    • Currently used monitor current monitor useage
      Displays the monitors that are currently in use and includes their associated threads.
    • History Test Records historical usage
      Displays a history of significant wait events and blocking events.
    • Monitoring Usage Status Monitor usage statistics
      Displays statistical monitoring data for packet monitoring, threading, and monitoring classes.

5. VM Remote Sensing Survey technology VM telemetry

Observing the internal state of the JVM, Jprofiler provides a different view of the remote Sensing survey as follows:

    • Heaps heap
      Displays the usage and heap size activity schedule for a heap.
    • Recorded Objects Recorded objects
      Displays an activity schedule for a chart of active objects and arrays.
    • Garbage Collection Garbage collector
      Displays an activity schedule for the garbage collection activity.
    • Class Classes
      Displays the active timesheet for a chart with the loaded class.
    • Thread Threads
      Displays an activity schedule with a dynamic thread graph.

Third, actual combat

(i) Mission objectives

Find out why memory is growing in your project

(ii) Configuration instructions

Operating system: Windows2003

Web container: Tomcat5.0.23

JDK version: sun1.4.2

Monitoring type: Local

Jprofiler Installation path: D:/JPROFILER5

Tomcat Installation path: D:/TOMCAT5

(iii) test project

1. New Web Project Test

2. Build Package Cn.test

3. Under the package to build the class files Testmain.java and Testbean.java

Package cn.test;

public class Testbean {

String name = "";

}

Package cn.test;

import java.util.ArrayList;

Publicclass Testmain {

publicstatic ArrayList List = new ArrayList (); Container for storing objects

public static int counter = 0; For statistical purposes

}

4. Built-in JSP files for testing init1.jsp, init2.jsp

init1.jsp (10,000 Testbean objects are created per execution)

<%@ page language= "java" import= "cn.test.*" pageencoding= "Iso-8859-1"%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

<title>init</title>

<body><%

for (int i=0;i<10000;i++) {

Testbean B = new Testbean ();

TestMain.list.add (b);

}

%>

Size:<%=testmain.list.size ()%><br/>

Counter:<%=testmain.counter++%>

</body>

Init2.jsp and init1.jsp are exactly the same (useful later).

(iv) Configuring test Cases

1. Click D:/jprofiler5/bin/jprofiler.exe

2. Execution Menu Sessionàintegration wizardsànew serverintegration

Choose whether to test locally or remotely:

Select the script file that Tomcat runs:

Select the type of virtual machine:

Select the monitoring port:

With the default, you can

Select whether the Web container runs with Jprofiler:

By default you can

Configuration tips:

You should read it carefully when you are "remote control".

Then choose Start now to run.

Click "OK", we can see another small window came out:

The Jprofiler window is:

So we can monitor it!

(v) Start testing

1. In the IE Address bar, enter: http://localhost/test/init1.jsp, execute once, we can see in memory view the Cn.test.TestBean object was created 10,000 times:

2. Mark the current state, then execute init1.jsp and, init2.jsp can let us find which classes are not released after the call (very important!!!). )

See which classes have changed:

The red becomes the object of change and its number.

I have just executed 4 init1.jsp and 1 init2.jsp, which produced 50,000 Testbean objects, just like the one shown in the illustration.

3. After a while, press the F4 key for garbage collection. But after the collection is complete, these objects still exist, indicating that references to this class have not been released in some places!

4. Find out where the Testbean classes are used and do not release them

Right-click on the Cn.test.TestBean object to select "Take Heap Snapshot for Selection" and observe its heap

Next:

Click "OK":

Right-click in the class and select "Use Selected Objects" in the menu that appears:

The following window appears:

Select "Allocations" and click "OK", and then we'll get the results.

The figure shows where this class is called init1.jsp and init2.jsp, and the respective ratios are listed.

Now that the problem is found, it's time to solve the problem!

(v) Summary

In fact, we can also write a free memory JSP file to match the test when we test the memory consumption, it will be clearer:

Free.sjp

<%@ page language= "java" import= "java.util.*,cn.test.*" pageencoding= "Iso-8859-1"%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

<title>init</title>

<body>

<%testmain.list.clear (); %> Collection ok!

</body>

After clicking on init1.jsp or init2.jsp, you can see that the number of Testbean objects is increased, then the FREE.SJP is executed, then the F4 is garbage collected, and immediately you can see that the Testbean object is released.

Reference Document Address:

Http://www.blogjava.net/anymobile/articles/28248.html

Jprofiler Detailed Usage Introduction (JVM Object memory thread monitoring tool) "Go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.