In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail the case of GC log analysis of Java virtual machine. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
I. Log analysis
Understanding GC logs is a basic skill in dealing with memory problems in Java virtual machines.
By adding parameters to the java command to specify the corresponding gc type, print gc log information and output to files and other strategies.
1. Write java code public class ReferenceCountingGC {public Object instance = null; private static final int ONE_MB = 1024 * 1024; private byte [] bigSize = new byte [2 * ONE_MB]; public static void main (String [] args) {testGC ();} public static void testGC () {ReferenceCountingGC objA = new ReferenceCountingGC () ReferenceCountingGC objB = new ReferenceCountingGC (); objA.instance = objB; objB.instance = objA; objA = null; objB = null; System.gc ();}} 2, compile java file javac ReferenceCountingGC.java3, execute class file java-XX:+PrintGCDateStamps-XX:+PrintGCDetails ReferenceCountingGC
Corresponding parameter list
-XX:+PrintGC output GC log
-XX:+PrintGCDetails outputs the detailed log of GC
-XX:+PrintGCTimeStamps outputs the timestamp of the GC (in the form of base time)
-XX:+PrintGCDateStamps outputs the timestamp of the GC (in the form of a date, such as 2013-05-04T21:53:59.234+0800)
-XX:+PrintHeapAtGC prints out heap information before and after GC
-output path of Xloggc:../logs/gc.log log file
Result output:
2016-03-20T14:34:55.118-0800: [GC [PSYoungGen: 6123K-> 400K (38912K)] 6123K-> 400K (125952K), 0.0012070 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2016-03-20T14:34:55.119-0800: [Full GC [PSYoungGen: 400K-> 0K (38912K)] [ParOldGen: 0K-> 282K (87040K)] 400K-> 282K (125952K) [PSPermGen: 2622K-> 2621K (21504K)], 0.0084640 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
Heap
PSYoungGen total 38912K, used 1013K [0x00000007d5500000, 0x00000007d8000000, 0x0000000800000000)
Eden space 33792K, 3% used [0x00000007d5500000pr 0x00000007d55fd7d0pl 0x0000000007d7600000)
From space 5120K, 0% used [0x00000007d76000000x00000007d76000000x00000007d7b00000)
To space 5120K, 0% used [0x00000007d7b000005d0x00000007d7b000005d0x00000007d8000000)
ParOldGen total 87040K, used 282K [0x0000000780000000, 0x0000000785500000, 0x00000007d5500000)
Object space 87040K, 0% used [0x00000007800000000x0000000780046bf8 0x0000000785500000)
PSPermGen total 21504K, used 2628K [0x000000077ae00000, 0x000000077c300000, 0x0000000780000000)
Object space 21504K, 12% used [0x000000077ae000x000000077b091380mem0x000000077c300000)
PSYoungGen stands for the new generation, and the name is determined by the collector, which here is Parallel Scavenge. The old age is ParOldGen, and the permanent substitute is PSPermGen.
If the collector is a ParNew collector, the new generation is ParNew,Parallel New Generation
If the collector is a Serial collector, the new generation is DefNew,Default New Generation
You can see that there are two types of GC above: GC and Full GC. Full indicates that Stop-The-World has occurred in GC this time.
New generation GC (Minor GC): refers to the garbage collection actions that occur in the new generation. Because most Java objects have the characteristics of dying out, Minor GC is very frequent, and the collection speed is generally very fast.
Old GC (Major GC/Full GC): refers to the GC occurred in the old years, the emergence of Major GC, often accompanied by at least once the speed of Minor GC,Major GC is generally more than 10 times slower than Minor GC.
[GC [PSYoungGen: 6123K-> 400K (38912K)] 6123K-> 400K (125952K), 0.0012070 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
The 6123K-> 400K (38912K) inside the square brackets above indicates that the memory area has been used before GC-> the memory area has been used since GC, and the 38912K inside the parentheses is the total capacity of the memory area.
The 6123K-> 400K (125952K) outside the square brackets indicates the used capacity of the Java heap before GC-> the used capacity of the Java heap after GC, and the 125952K inside the parentheses is the total capacity of the Java heap.
[Times: user=0.00 sys=0.00, real=0.00 secs] refers to the CPU time consumed by the user, the CPU time consumed in the kernel state, and the wall clock time (Wall Clock Time) elapsed by the operation from start to finish. The difference between the wall clock time and the wall clock time is that the wall clock time includes a variety of non-operational waiting time, such as waiting for disk ICPU O and waiting for thread blocking, while CPU time does not include these time.
This is the end of this article on "the case of GC log analysis of Java virtual machine". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.