Java memory analysis summary, java memory Summary

Source: Internet
Author: User
Tags jconsole

Java memory analysis summary, java memory Summary

1. built-in jconsole tool.

(1) If it is started from the command line, make JDK on the PATH and run jconsole.

(2) If you start from the GUI shell, find the JDK installation path, open the bin folder, and double-clickJconsole.

(3) When the analysis tool pops up (depending on the running Java version and the number of running Java programs), a dialog box may appear asking you to enter a process URL to connect,

It is also possible to list many different local Java processes (sometimes including the JConsole process itself) for connection.

Reference http://jiajun.iteye.com/blog/810150

2. built-in jmap Tool

Jmap is a tool that can output all objects in the memory. It can even output heap in the VM in binary format as text. Use jmap-histo pid. If you use SHELL jmap-histo pid>. log can save it to the text (which can also be used in windows). After a period of time, you can use the text comparison tool to compare which objects are collected by GC.

(1) DOS query port and PID in windows: TaskList/svc
(2) Use the netstat-ano command to list the PID corresponding to all ports

3. mat

A. Generate a dump file

A process corresponds to a. hprof file,
(1) set jvm parameters:-XX: + HeapDumpOnOutOfMemoryError. The java_pid7888.hprof file is located in the current project directory;
(2) Using jmap-dump: format = B, file = HeapDump. bin <pid>

(3) generated through jconsole

Choose Mbean> com. sun. management> HotSpotDiagnos> Operations> dumpHeap.

In the p0 parameter, enter the path for saving the dmp file, for example, f:/my. hprof. The extension name of the file must be hprof.

Click dumpHeap to generate the dump file.

B. Install mat and open the. hprof file for analysis.


JAVA memory Analysis

In other words, "3" and "5" should be the same as the variable name, the basic type.

Java memory Analysis

Very simple. "Hello World" has been created for temporary storage during construction.
String temp = "Hello World ";
String str = new String (temp)

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.