Performance Analysis Tool JProfile User Guide

Install JProfile

1.1 Install the JProfile plugin in IDEA

  • Click File->Setting->Plugins in the idea, enter the plug-in page, search for JProfile, click install to download and install, restart idea after success
    insert image description here
  • Open the idea and see the JProfile icon above the idea, indicating that the plug-in is installed successfully
    insert image description here

1.2 Download and install JProfiler client

Official website URL: https://www.ej-technologies.com/products/jprofiler/overview.html
License required

1.3 IDEA configures JProfiler executable file

Generally speaking, IDEA will automatically add the path of the JProfiler executable file, as shown in the figure:
insert image description here

2 Monitoring view

2.1 JProfiler monitoring

Select the item to be monitored, click the button, and the JProfiler window will pop up automatically, and you can monitor your own code performance.
insert image description here
If the code runs very fast, it will not be detected. You can set sleep or use keyboard input to control the code to run and observe the performance change.

/**
 * 配合性能检测工具Jprofiler使用,键盘控制开始和结束
 */
Scanner in = new Scanner(System.in);
System.out.println("可以开始监测构建网格了吗:");
String a = in.next();
//待监测的运行代码块
System.out.println("可以结束监测了吗:");
String c = in.next();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

insert image description here

2.2 Memory view (Live memory)

The memory view section of JProfiler provides dynamically updated views of memory usage and views that display information about memory allocations. All views have several aggregation layers and can display both existing objects and objects that are being garbage collected.

2.2.1 All objects (ALL objects)

The All Objects view shows a list of all loaded classes and the number of instances allocated on the heap.
insert image description here

To view allocations of objects for a specific time period, and record the call stack of the allocation, use the Recorded Objects View. Here is an aggregate level selector, you can switch between the following types, as shown in the figure:
 classes (classes): each row displays a single class, which is the default aggregate type
 packages (packages): each One line shows a single package, subpackages are not included. Within this aggregate level, tables are tree-shaped. You can click on the tree node to view the classes it contains, as shown in Figure
 J2EE components (J2EE components): Each row is a J2EE component. This pattern is similar to the filter in the class pattern, allowing you to quickly inspect the J2EE components loaded in the application.
insert image description here
insert image description here

Three rows are displayed in the table, which can be sorted and viewed.
 Name: Display class, package or J2EE according to the aggregate level.
 Number of instances:
 Size: Display the actual total size of all allocations. Only the size of the corresponding pointer is included, the size of reference arrays and instances is not included. Displayed in bytes. Only object data is included, not the JVM size used by the class, nor class data and local variable sizes.

insert image description here

2.2.2 Recorded objects

The Logged Objects view shows a list of all logged objects and arrays, including the number of instances allocated on the heap. Only logged objects are displayed in this view. If a package or class is selected, you can jump from the record object view to the allocation call tree and allocation hotspots. The method is to right-click and select the view to jump to.
You can add packages or classes to the class tracker. If the class tracker is not recording, start recording all classes configured in the class tracker; if recording a different object type, all the recording data is cleared.
insert image description here
The logged object view can be filtered based on the liveness of the objects:
 Live objects (Live objects)
show only objects currently in memory
 Garbage collected objects (Garbage collected objects)
are shown collected objects
 Live and garbage collected objects (Live and garbage collected objects)
displays all created objects
insert image description here

2.2.3 Allocation call tree (Allocation call tree)

Allocation call tree view displays a request tree or method, class, package, or J2EE component with annotated allocation information for the selected class
insert image description here

2.2.4 Allocation hot spots view

The Allocation Hotspot view shows a list of methods where objects of the selected class are allocated. Only methods that are assigned to at least 1% of the total are displayed. Methods can be filtered according to active filter sets settings. This view is somewhat similar to the hot spots view in the CPU section, except that it shows the number of instances and arrays of allocated classes instead of time metrics.
For each hotspot, its trace tree can be displayed.
insert image description here

2.2.5 Class tracker

For each class, there is class tracking.
insert image description here

2.3 Heap Walker

2.3.1 Classes¶

Show all classes and their instances
insert image description here
by class loader:
insert image description here
insert image description here

2.3.2 Allocations

Displays allocation tree and allocation hotspots for all record objects

2.3.3 Index (References)

Provides display of index graphs for individual objects and "show path to garbage collection root". Also provides
the ability to merge input and output views
insert image description here

2.3.4 Data

Display instance and class data for a single object
insert image description here

2.3.5 Time (Time)

Displays a histogram of resolution times for recorded objects

2.4 CPU view

2.4.1 Call tree view (Call tree view)

The call tree shows a thread calling tree from top to bottom. The display can be filtered up or down according to the filter settings.
JProfiler automatically detects J2EE components and displays the associated nodes in the call tree. Use different icons to display
different J2EE component types
 servlets: yellow inverted heart
 JSPs: blue inverted heart
 EJBs: red inverted heart
insert image description here
For JSPs and EJBs, JProfiler displays the names as:
 JSPs: JSP source file path
 EJBs: EJB interface name
If the URL can be subdivided, each URL request uses a special symbol to create a new node with URL: do, followed by the subdivided URL request call tree view aggregate level selection
Yes Four:
 Method, which is also the default level. Each node is a method call. Special J2EE component methods have their own icons and display names, mentioned above. The real class name is enclosed in square brackets
 Class: Each node is a separate class. Special J2EE component methods have their own icons and display names, mentioned above. The actual class name is enclosed in square brackets
 Package: Each node is a separate package. Does not include subpackages
 J2EE component: each node is a J2EE component, if the component has an independent display name, the real class name is omitted.
The call tree does not show all methods in the JVM, only:
 Unfiltered classes: Classes that are not filtered according to your configured filter settings
 First level calls of unfiltered classes: Calls from unfiltered classes to filtered classes The first-level call, the call to the deeper level of the filter class is not displayed. Filtered nodes are marked in red in the upper left corner.
 Thread entity method: The method Runnable.run() and the main method are always displayed, no matter whether it is filtered or not. If the
percentage bar mode is set in the view settings, each node in the call tree will display
a percentage bar, showing the current The percentage of the node's internal time to the total time, the current node includes all its descendant nodes
and the red highlighted part

2.4.2 Hot spot view

The hotspot view displays a list of calls of the selected type. Points that account for less than 0.1% of the total time are truncated.
The hot spot type can be selected in the drop-down of "hot spot type", including two types:
 method calls (method calls)
method calls (show filtered classes separately): calculate the displayed hot spots from the method calls, and the filtered classes calculate their own hot spots, This mode is the default.
method calls (add filtered classes to calling class): Calculate the displayed hotspots from method calls, and the called class is added to the calling class, unless it is a thread entity method (run and main method)
insert image description here

2.4.3 Call graph (Call graph)

The call graph statically displays the call graph for the threads computed by the selected node. Nodes can be methods, classes, packages or J2EE
components.
To calculate the call graph, click Generate graph in the toolbar or select View->Generate graph.
Before the graph calculation, the call graph wizard is launched. The resulting graph is static and can be recalculated. The call
graph wizard keeps track of your most recent options.
insert image description here

3. Combined with the practical application of the algorithm

3.1 Memory rises rapidly

Generally speaking, you will pay attention to heap memory, because memory leaks are mainly in the heap. If the memory curve continues to be high, continues to rise, or suddenly rises at a certain point, it is considered a problem.
insert image description here
First check the Classes tab to check the number of objects and memory usage:
insert image description here
Note: As can be seen from the figure, char[] and String objects take up a lot of memory, so we mainly analyze these two objects. In addition, there are Integer and BigDiecimal, The occupancy is also relatively high and needs to be analyzed.
Then click the Biggest Objects tab to view the largest object in the entire heap to see if it is used by a large object: Note
insert image description here
: As can be seen from the figure, there are two objects that occupy a very large amount of memory. Many, so we mainly analyze these two objects, why they occupy such a high memory
Expand the tree, and find that all objects are referenced in the ICMP discovery class:
insert image description here
Note: From here we can see that all String objects are referenced by this class The referenced attribute is list, and the type is ArrayList.
Right-click the class, select Use Selected Objects, and select Reference in the pop-up interface:

看到的数据是25000个小区的信息缓存在list中,然后构建网格时,又存入到新的list中。

 
 
  
  
  • 1

Guess you like

Origin blog.csdn.net/weixin_42218169/article/details/131888934