Java Memory leakage troubleshooting notes

Source: Internet
Author: User

Recently, applications occasionally run out of memory in the Java heap, with 100% CPU and no response from the application. Using jmap-histo PID (process number), dump the current memory Java object information,

 

Num # instances # bytes Class Name
----------------------------------------------
1: 23883422 1383659120 [ljava. Lang. object;
2: 38566123 1234115936 java. Lang. String
3: 38576360 1037800072 [C
4: 31742957 1015774624 com. qidea. gameserver. subsys. battlesys. battletapeunit
5: 10038906 803112480 com. qidea. gameserver. subsys. battlesys. battletapeunithurt
6: 23865403 572769672 java. util. arraylist
7: 7935551 444390856 com. qidea. gameserver. subsys. battlesys. battletapeunitfight
8: 11808162 283397352 [F
9: 6605214 211366848 java. util. hashmap $ entry
10: 3122289 149869872 com. qidea. Game. Map. maplandtable
11: 66126 94220344 [B
12: 82414 43991784 [ljava. util. hashmap $ entry;
13: 118473 17773488 <constmethodklass>
14: 118473 16124280 <methodklass>
15: 13767 14909176 <constantpoolklass>
16: 12466 10045840 <constantpoolcacheklass>
17: 13767 9999456 <instanceklassklass>
18: 232564 9155008 [I
19: 159971 9122656 <symbolklass>
20: 126653 7092568 org. Apache. tomcat. util. Buf. messagebytes
21: 147424 7076352 org. Apache. tomcat. util. Buf. bytechunk
22: 211044 6753408 java. SQL. Timestamp
23: 129619 5184760 org. Apache. tomcat. util. Buf. charchunk
24: 7213 4683984 <methoddataklass>
25: 82978 4646768 org. objectweb. ASM. Item
26: 52466 4617008 java. Lang. Reflect. Method
27: 188251 4518024 org. objectweb. ASM. Edge
28: 58425 3739200 org. objectweb. ASM. Label
29: 63797 3062256 java. util. hashmap
30: 125571 3013704 java. Lang. Long
31: 64031 2561240 java. util. javashashmap $ entry
32: 71741 1853696 [ljava. Lang. String;
33: 44056 1762240 java. Lang. Ref. softreference
34: 108406 1734496 java. Lang. Integer
35: 35404 1699392 com. qidea. gameserver. subsys. herosys. rolebattlearray
36: 14821 1541384 com. qidea. gameserver. subsys. citysys. City
37: 14421 1499784 java. Lang. Class
38: 41691 1334112 java. util. hashtable $ entry
39: 23833 1143984 org. aspectj. Weaver. Reflect. shadowmatchimpl
40: 69888 1118208 java. Lang. Float
41: 33705 1078560 java. util. Concurrent. concurrenthashmap $ hashentry
42: 33548 1073536 org. Apache. tomcat. util. http. mimeheaderfield
43: 33529 1072928 java. Lang. Ref. weakreference
44: 5476 1051392 org. objectweb. ASM. methodwriter

45 :...................................... .........................

 

We found that the objects battletapeunit, battletapeunithurt, and battletapeunitfight are abnormal. Based on the class information, we found the Code related to these classes in the code, and solved some problems. After modifying the relevant code, I re-released the application and ran for a week. The memory was stable and the problem was solved.

I have seen on the Internet that using jmap to dump all heap memory images and using eclipse mat to solve the memory leakage problem. I don't think it is necessary, first, after my application crashes, the heap is full. At this time, the memory image dumped out by dump is a few hundred MB and several GB larger. Our application is 8 GB. It is troublesome to download such a large image from the official environment. Secondly, we use mat for analysis and there is too much information to capture important information at once. Compared with jmap-histo, jmap-histo is simpler and faster.

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.