Java runtime data area-----java heap overflow + virtual machine stack overflow/native method stack overflow + method area overflow + constant pool overflow + direct native memory overflow

Java heap overflow: A memory overflow exception occurs when the number of objects reaches the capacity limit of the maximum heap.

Virtual machine stack overflow/local method stack overflow: The depth of the request stack reaches the maximum depth allowed by the virtual machine, and a StackOverError exception is thrown. When the stack is expanded, it will be thrown if it cannot apply for enough memory space, and an OutOfMemoryError exception will be thrown. In the single-threaded case, only StackOverError exceptions can be thrown in these two cases.

Method area overflow + constant pool overflow: String.intern() is a native method. Its function is: if the string constant pool already contains a string equal to this String object, it returns the string representing the string in the pool. String object, otherwise, add the reference of this string to the constant pool, and return the reference of the String object.

In JDK1.6, the intern() method will copy the string instance encountered for the first time into the permanent generation, and return a reference to the string in the permanent generation, and the string instance created by StringBuilder is on the java heap, It must not be the same reference, and after 1.7, the intern() method will record the reference of the first encountered string in the constant pool, so it is the same reference as StringBuilder.

The local memory overflows directly: wait for the second time to write.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325993075&siteId=291194637