Java Memory Overflow Classification __java

Source: Internet
Author: User
Tags garbage collection unpack

About Java Overflow classification, I often encounter two categories: one is Java.lang.OutOfMemoryError:Java heap space, a class is Java.lang.OutOfMemoryError:PermGen space.

In these two categories, the former encounter more frequent. Because the Java heap space situation, sometimes not enough memory, it will also throw this error message. For example, I have encountered this situation, I was found through the GC log, memory currently occupies about 40MB (maximum allocation 512MB), very puzzled. The final check shows that there are two situations that can lead to this situation:

One is the thread stack is not enough, for the Sun JVM is set XSS parameters, in general, the thread stack set 256K is already a lot of, generally do not cause such errors, unless you set too small, will cause.

One is that a thread is currently creating an object that is larger than the allocated space, and you may find it inconceivable that no such object will ever be created. However, in some scenarios, such an error occurs, such as when the protocol is unpack, if a string type of field, the type of int to unpack, with this value as the size of the creation of a one-dimensional array, it is very likely that this situation.

Of course, most of the cases I have encountered are the latter.

When there is not enough memory, naturally throw Java.lang.OutOfMemoryError:Java heap space, this situation will eventually cause Java programs to stop external services. There are a lot of things that can be referred to in my other article, "Java Memory management."

The explanation for PermGen space is simple and straightforward, and here I give the definition of the Web:

PermGen space This section is used to store class and meta information, class is placed in the PermGen space area when it is load, and is different from the heap area where instance is stored, GC (garbage Collection) PermGen space will not be cleaned up during the main program run, so if your app will load a lot of classes, PermGen space error is likely to occur.

General program appears PermGen space error, the program process will sometimes shut down automatically.

The general solution is to set the JVM's permsize parameter values to increase (but this is only a symptom and not the root causes, temporarily extended the server's operational life). However, this is caused by the use of cglib on the Internet. Just recently (after server optimization), my server also encountered this problem (but I did not use the third library of Cglib), so I need to verify the validation, and then tell whether it is valid (the problem has been resolved, refer to my another "PermGen space Situation").

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.