Java memory overflow analysis tool: actual use of jmap

Source: Internet
Author: User

Jmap is used to solve the problem of system tomcat always holding the memory to the header and then crashing.
1. Use commands
If the environment is linux + jdk1.5 or above, this tool comes with the path under JDK_HOME/bin /.
Jmap-histo pid> a. log

2. output result summary
Size Count Class description
353371288 9652324 char []
230711112 9612963 java. lang. String
139347160 114865 byte []
76128096 3172004 java. util. Hashtable $ Entry
75782280 3157595 com. test. util. IPSeeker $ IPLocation
25724272 9115 java. util. Hashtable $ Entry []
9319968 org. apache. tomcat. util. buf. MessageBytes
8533856 32889 int []

A large number of strings and custom object com. test. util. IPSeeker $ IPLocation exist. Check the program and find that memory overflow exists here. After the modified program goes online, it uses jmap to capture memory data again:

146881712 207163 byte []
98976352 354285 char []
42595272 53558 int []
11515632 479818 java. util. HashMap $ Entry
9521896 59808 java. util. HashMap $ Entry []
8887392 370308 com. test. bean. UnionIPEntry
8704808 org. apache. tomcat. util. buf. MessageBytes
8066880 336120 java. lang. String

Eliminate memory overflow.
Note: When using this jmap, the jvm is in a suspended state and can only be used to solve the problem when the service is paralyzed. Otherwise, service interruption may occur.

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: 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.