In eclipse dump, how does one use Java memory and print GC logs?

Source: Internet
Author: User
When using Java to develop applications Program When memory leakage occurs, dump memory is often required, and then memory analysis tools such as Eclipse memory analyzer (usually called mat) are used.


This article describes how to dump memory in eclipse. Preparation in advance: 1. Download mat: http://www.eclipse.org/mat/ 2. Test Code As follows:
 
Package COM. memoryleakanalysis; import Java. util. arraylist; import Java. util. list; public class memoryleakdemo {public static void main (string [] ARGs) {list <string> List = new arraylist <string> (); While (true) {list. add ("outofmemoryerror soon ");}}}

Right-click Run events to find arguments -----> VM arguments and enter:-XX: + heapdumponoutofmemoryerror
-XX: heapdumppath = C:/memoryleakdemo. hprof
-XX: + printgcdetails
-XX: + printgcdatestamps
-XX: + printgcapplicationconcurrenttime
-XX: + printgcapplicationstoppedtime
-Xloggc: C:/memoryleakdemogc. Log

Click Run. Memory Dump: Two files will appear in the C:/test directory: For example:
Memoryleakdemo. hprof indicates the dump memory. Memoryleakdemogc. log is used for jvm gc garbage collection.Eclipse memory analyzer (MAT) EnabledMemoryleakdemo. hprof
To see the suspicious Memory leakage, such:

Open Memoryleakdemogc. log: Similar to the case, you can analyze the garbage collection based on logs to analyze the JVM memory usage. For details about how to analyze GC logs, go to Google and write logs in the future.ArticleIntroduction. Application Time: 0.0072104 seconds
2013-06-21t18: 08: 09.518 + 0800: 0.079: [GC 0.079: [defnew: 4017 K-> 261 K (4928 K ), 0.0020189 secs] 4017 K-> 1425 K (15872 K), 0.0020804 secs] [times: User = 0.00 sys = 0.00, real = 0.01 secs]
Total time for which application threads were stopped: 0.0118427 seconds
Application Time: 0.0015514 seconds
2013-06-21t18: 08: 09.531 + 0800: 0.092: [GC 0.092: [defnew: 2095 K-> 0 K (4928 K ), 0.0022178 secs] 3258 K-> 3170 K (15872 K), 0.0022986 secs] [times: User = 0.00 sys = 0.00, real = 0.00 secs]
Total time for which application threads were stopped: 0.0023873 seconds
Application Time: 0.0021970 seconds
2013-06-21t18: 08: 09.536 + 0800: 0.097: [GC 0.097: [defnew: 2618 K-> 0 K (4928 K ), 0.0027436 secs] 5788 K-> 5788 K (15872 K), 0.0027797 secs] [times: User = 0.00 sys = 0.00, real = 0.00 secs]
Total time for which application threads were stopped: 0.0029137 seconds
Application Time: 0.0033047 seconds
2013-06-21t18: 08: 09.542 + 0800: 0.103: [GC 0.103: [defnew: 3927 K-> 0 K (4928 K), 0.0040692 secs] 0.107: [tenured: 9715 K-> 4188 K (10944 K), 0.0078907 secs] 9715 K-> 4188 K (15872 K), [perm: 376 K-> 376 K (12288 K)], 0.0120529 secs] [times: User = 0.00 sys = 0.00, real = 0.01 secs]
Total time for which application threads were stopped: 0.0121337 seconds
Application Time: 0.0051220 seconds
2013-06-21t18: 08: 09.559 + 0800: 0.120: [GC 0.120: [defnew: 0 k-> 0 K (4992 K), 0.0019689 secs] 0.122: [tenured: 10078 K-> 6151 K (10944 K), 0.0086661 secs] 10078 K-> 6151 K (15936 K), [perm: 376 K-> 376 K (12288 K)], 0.0107276 secs] [times: User = 0.00 sys = 0.00, real = 0.01 secs]
Total time for which application threads were stopped: 0.0108428 seconds
Application Time: 0.0088859 seconds
2013-06-21t18: 08: 09.579 + 0800: 0.140: [GC 0.140: [defnew: 0 k-> 0 K (4992 K), 0.0026499 secs] 0.143: [tenured: 14987 K-> 9097 K (19780 K), 0.0113583 secs] 14987 K-> 9097 K (24772 K), [perm: 376 K-> 376 K (12288 K)], 0.0141102 secs] [times: User = 0.02 sys = 0.00, real = 0.01 secs]
Total time for which application threads were stopped: 0.0142300 seconds
Application Time: 0.0131855 seconds
2013-06-21t18: 08: 09.606 + 0800: 0.167: [GC 0.167: [defnew: 0 k-> 0 K (8960 K), 0.0041453 secs] 0.172: [tenured: 22350 K-> 13514 K (33036 K), 0.0153709 secs] 22350 K-> 13514 K (41996 K), [perm: 376 K-> 376 K (12288 K)], 0.0196298 secs] [times: User = 0.01 sys = 0.00, real = 0.02 secs]
Total time for which application threads were stopped: 0.0197569 seconds
Application Time: 0.0192821 seconds
2013-06-21t18: 08: 09.646 + 0800: 0.207: [GC 0.207: [defnew: 0 k-> 0 K (14976 K), 0.0057633 secs] 0.212: [tenured: 33395 K-> 20141 K (52920 K), 0.0206766 secs] 33395 K-> 20141 K (67896 K), [perm: 376 K-> 376 K (12288 K)], 0.0265551 secs] [times: User = 0.03 sys = 0.00, real = 0.03 secs]
Total time for which application threads were stopped: 0.0266673 seconds
Application Time: 0.0289176 seconds
2013-06-21t18: 08: 09.701 + 0800: 0.262: [GC 0.262: [defnew: 0 k-> 0 K (23872 K), 0.0086104 secs] 0.271: [tenured: 49962 K-> 30081 K (52920 K), 0.0294036 secs] 49962 K-> 30081 K (76792 K), [perm: 376 K-> 376 K (12288 K)], 0.0380994 secs] [times: User = 0.03 sys = 0.00, real = 0.04 secs]
Total time for which application threads were stopped: 0.0382799 seconds
Application Time: 0.0436154 seconds
2013-06-21t18: 08: 09.783 + 0800: 0.344: [GC 0.344: [defnew: 0 k-> 0 K (23872 K), 0.0131421 secs] 0.357: [tenured: 74812 K-> 44992 K (97652 K), 0.0415558 secs] 74812 K-> 44992 K (121524 K), [perm: 376 K-> 376 K (12288 K)], 0.0548393 secs] [times: User = 0.05 sys = 0.00, real = 0.06 secs]
Total time for which application threads were stopped: 0.0550578 seconds
Application Time: 0.0657430 seconds
2013-06-21t18: 08: 09.904 + 0800: 0.465: [GC 0.465: [defnew: 0 k-> 0 K (43968 K), 0.0198380 secs] 0.485: [tenured: 112088 K-> 67357 K (164752 K), 0.0608105 secs] 112088 K-> 67357 K (208720 K), [perm: 376 K-> 376 K (12288 K)], 0.0807997 secs] [times: User = 0.08 sys = 0.00, real = 0.08 secs]
Total time for which application threads were stopped: 0.0809335 seconds
Application Time: 0.0991039 seconds
2013-06-21t18: 08: 10.084 + 0800: 0.645: [GC 0.645: [defnew: 0 k-> 0 K (74240 K), 0.0293317 secs] 0.674: [tenured: 168002 K-> 100905 K (174784 K), 0.0895410 secs] 168002 K-> 100905 K (249024 K), [perm: 376 K-> 376 K (12288 K)], 0.1189829 secs] [times: User = 0.12 sys = 0.00, real = 0.12
Secs]
2013-06-21t18: 08: 10.203 + 0800: 0.764: [full GC 0.764: [tenured: 100905 K-> 100892 K (174784 K ), 0.0861601 secs] 100905 K-> 100892 K (253440 K), [perm: 376 K-> 371 K (12288 K)], 0.0862167 secs] [times: user = 0.08 sys = 0.00, real = 0.09 secs]
Total time for which application threads were stopped: 0.2053870 seconds
Application Time: 0.0006161 seconds
Total time for which application threads were stopped: 0.5625090 seconds
Heap
Def New Generation total 78656 K, used 2190 K [0x24690000, 0x29be0000, 0x29be0000)
Eden space 69952 K, 3% used [0x24690000, 0x248b3bd8, 0x28ae0000)
From space 8704 K, 0% used [0x28ae0000, 0x28ae0000, 0x29360000)
To space 8704 K, 0% used [0x29360000, 0x29360000, 0x29be0000)
Tenured generation total 174784 K, used 100892 K [0x29be0000, 0x34690000, 0x34690000)
The space 174784 K, 57% used [0x29be0000, 0x2fe67208, 0x2fe67400, 0x34690000)
Compacting perm Gen total 12288 K, used 371 K [0x34690000, 0x35290000, 0x38690000)
The space 12288 K, 3% used [0x34690000, 0x0000ecf38, 0x0000ed000, 0x35290000)
RO space 10240 K, 55% used [0x38690000, 0x38c11140, 0x38c11200, 0x39090000)
RW space 12288 K, 55% used [0x39090000, 0x0000344c8, 0x39734600, 0x39c90000)
Application Time: 0.0016332 seconds


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