Jmap is used once to solve the problem that Tomcat always sticks to the memory and crashes.
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.