JVM [7]: [outofmemoryerror: A pool overflow occurs when an exception occurs]

Source: Internet
Author: User

To add content to the runtime pool, use the string. Intern () Native method. The function of this method is: if the pool already contains a string equal to this string object, a string object representing this string in the pool is returned; otherwise, add the string contained in this string object to the constant pool and return a reference to this string object. Since the constant pool is allocated in the method area, we can use-XX: permsize and-XX: maxpermsize to limit the size of the Method Area and indirectly limit the capacity of the output pool. The Code is as follows:

Package OOM; import Java. util. arraylist; import Java. util. list;/*** run time pool overflow * @ author Madison * @ date 2014-7-11 * VM ARGs:-XX: permsize = 10 m-XX: maxpermsize = 10 m */public class runtimeconstantpooloom {public static void main (string [] ARGs) {// use list to keep constant pool reference, avoid full GC collection of constant pool behavior list <string> List = new arraylist <string> (); int I = 0; while (true) list. add (string. valueof (I ++ ). intern ());}}

Running result:

Exception in thread "Main" Java. Lang. outofmemoryerror: permgen Space

At java. Lang. String. Intern (native method)

At oom. runtimeconstantpooloom. Main (runtimeconstantpooloom. Java: 20)

From the running results, we can see that the runtime frequent volume pool overflows. After the outofmemoryerror is followed by the prompt message "permgen space", indicating that the runtime frequent volume pool belongs to the method zone (permanent generation in the hotspot virtual machine).

I want to know what to do later and listen to the next Decomposition



This article is from the "2377209" blog. For more information, contact the author!

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.