In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to understand the GC overhead limit exceeded error of JVM, I believe that many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
There are several brothers in java, such as java.lang.OutOfMemoryError: Java heap space that I wrote yesterday and java.lang.OutOfMemoryError: GC overhead limit exceeded that I am going to write today. To understand this knowledge, we need to have a deep understanding of the underlying principles and implementation mechanism of JVM.
So let's talk about java.lang.OutOfMemoryError: GC overhead limit exceeded in detail today.
As we all know, one of the major advantages of the Java language is memory management, which is the garbage collection mechanism. Compared with other languages, such as C++, there is no automatic memory collection mechanism in these languages, which requires programmers to manually write code to allocate and release memory in order to reuse heap memory.
It is precisely because the Java language has an automatic garbage collection mechanism that some programmers will have a series of unexpected OutOfMemoryError if they use it improperly. There are 8 kinds of OutOfMemoryError errors at present, let's fix them one by one!
Java.lang.OutOfMemoryError: GC overhead limit exceeded this happens because the program basically uses up all the available memory and GC can't clean it up.
It would be more accurate to say that the proportion of time spent performing garbage collection is too large and the amount of effective computation is too small. By default, if GC takes more than 98% of the time and GC reclaims less than 2% memory, JVM will throw this error.
Java.lang.OutOfMemoryError: GC overhead limit exceeded errors are thrown only in extreme cases where GC has been recycled less than 2% several times in a row. What happens if you don't throw a GC overhead limit error? That is, with so little memory cleared by GC, it will soon fill up again, forcing GC to execute again. This creates a vicious circle, where CPU usage has always been 100%, while GC has achieved nothing. The system user will see the system jammed. It used to take only a few milliseconds to operate, but now it takes several minutes to complete.
Let's take a look at an example of a "GC overhead limit exceeded" error:
To see the effect more quickly, we can set the parameters of JVM:
It should be noted that there are different GC algorithms. The error messages generated are also different, and some may generate java.lang.OutOfMemoryError: Java heap space errors.
About the specific GC algorithm, I will give you a list of Java8 GC algorithms, and I will write a specific article to talk about it later.
Let's talk about the code above that produces OutOfMemoryError errors. Map throws a java.lang.OutOfMemoryError error message while doing rehash. If you use another garbage collection algorithm, such as-XX:+UseConcMarkSweepGC, or-XX:+UseG1GC, the error will be caught by the default exception handler, but there is no stacktrace information, because there is no way to populate the stacktrace information when the Exception is created.
For example, some vendors' JVM is configured with the following UseG1GC in the Win7x64,Java8 environment:
The resulting error message is:
These real cases above show that in the case of resource constraints, it is impossible to accurately predict which specific reason the program will die. Therefore, in the face of such errors, you can not tie up a particular error handling order.
Some people configure the following startup parameters when resolving the "java.lang.OutOfMemoryError: GC overhead limit exceeded" error:
I'm telling you, this is a complete mistake. Because the use of UseGCOverheadLimit in this way does not really solve the problem, it can only delay the occurrence of out of memory errors a little bit, and other processing will have to be done in the end. Specifying this option masks the original java.lang.OutOfMemoryError: GC overhead limit exceeded error into a more common java.lang.OutOfMemoryError: Java heap space error message.
Sometimes GC overhead limit errors are triggered because there is not enough heap memory allocated to JVM. In this case, you only need to increase the heap memory size.
In most cases, increasing heap memory does not solve the problem. For example, there is a memory leak in the program, and increasing heap memory can only delay the generation of java.lang.OutOfMemoryError: Java heap space errors.
After reading the above, have you mastered how to understand the GC overhead limit exceeded error of JVM? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.