Java memory area and memory overflow exception

Source: Internet
Author: User

Javathe basic structure of a virtual machine

Class loading subsystem class loading subsystem is responsible for loading class information from the file system or network, and the loaded classes information is stored in a memory space called the method area. In addition to the class information, the method area may also hold the run-time-constant pool information, including string literals and numeric constants, which are memory-mapped portions of the constant pool part of the class file.
The Program Counter program counter is a small amount of memory space that can be thought of as the line number indicator of the byte code executed by the current thread. Basic functions such as branching, looping, jumping, exception handling, thread recovery, and so on, need to rely on this counter to complete.
Because the multithreading of a Java Virtual machine is implemented in a way that threads rotate and allocate processor execution time, at any given moment, a processor (a kernel for a multicore processor) executes only the instructions in one thread. Therefore, in order to recover the thread after switching to the correct execution location, each thread needs to have a separate program counter, the counters between the threads do not affect each other, isolated storage, we call this type of memory area is "thread-private" memory.
If the thread is executing a Java method, this counter records the address of the executing virtual machine bytecode instruction, or null (Undefined) If the Natvie method is being executed.
This memory area is the only area in the Java Virtual Machine specification that does not stipulate any outofmemoryerror conditions. JavaVirtual Machine StackThe thread is private, and its life cycle is the same as the thread. The basic behavior of thread execution is a function call, and each time the data of a function call is passed through the Java stack. The currently executing function lock corresponding frame is the current frame (at the top of the stack), it holds the current function of the local variables, intermediate operation results and other data. When the function returns, the stack frame is ejected from the stack. Java methods have two ways of returning functions, one is normal function return, using the return command, and the other is escaping the exception, regardless of which way, will cause the stack frame to be ejected. In a stack frame, you must include at least the local variable table, the operand stack, and several parts of the frame data area.

local Variable TableA local variable that is used to store method parameters and methods inside the definition. Variables in the local variable table are only valid in the current function call, and when the function call finishes, the local variable table is destroyed as the function stack frame is destroyed. When a Java program is compiled into a class file, the maximum capacity of the local variable table that the method needs to allocate is determined in the Max_locals data item of the method's Code property.
In the local variable table of the class file, the scope range, the index of the slot, the variable name, and the data type are displayed for each local variable.
When the method executes, the virtual machine uses the local variable table to complete the pass of the parameter value to the parameter list, and if it executes an instance method (non-static method), the No. 0-bit index in the local variable table is the application that is used to pass the object instance described by the method, that is, the this keyword.
Slots in a local variable table can be reused, and when the value of a PC counter exceeds the scope of a variable, the slot of the change amount can be overwritten by other variables.
Variables in the local variable table are also important garbage collection root nodes, as long as the objects referenced directly or indirectly by the local variable table are not recycled.
operand Stacks, the maximum depth of the operand stack is also written to the Max_stacks data item in the Code property at compile time. Each element of the operand stack can be any Java data type. When a method is just beginning to execute, the operand stack of this method is empty, and during the execution of the method, various bytecode instructions are written and extracted into the operand stack.
Stack Data area, Java stack frames also require some data to support constant pool parsing, normal method return, and exception handling.
A pointer to the constant pool is saved in the frame data area, allowing the program to access the constant pool. Each stack frame contains a reference to the method that the stack frame belongs to in the run-time pool that holds this reference to support dynamic connections during method invocation. When the virtual machine runs, the run-time pool holds a large number of symbol references, which can be seen as indirect references to each method. If the method representing stack frame A wants to invoke the method representing stack frame B, then the method invocation instruction of the virtual machine takes the symbolic reference of the B method as a parameter, but since the symbol reference does not point directly to the memory location representing the B method, you must also convert the symbol reference to a direct reference before the call. The real method can then be accessed through a direct reference. If a symbolic reference is converted to a direct reference during the class loading phase or when it is first used, the conversion becomes a static resolution, and if it is converted to a direct reference during run time, the conversion becomes a dynamic connection.
The return of the method is divided into two cases, one is normal exit, after exiting will be based on the definition of the method to determine whether to pass the return value to the upper level of the caller, one is the exception caused by the end of the method, this is not the return value to the upper layer of the calling method. However, either way the end of the method, when exiting the current method will jump to the current method is called the location, if the method is normal exit, the caller's PC counter value can be used as the return address, if the exception exits, it is necessary to pass the exception processing table to determine. A call to the method corresponds to the stack frame in the virtual machine stack in a stack of the stack operation, so the method exits may do things include: Restore the upper method of the local variable table and the operand stack, if there is a return value, the return value is pressed into the stack frame of the caller stack, It also adjusts the value of the PC counter to the next instruction in the method invocation entry.
Exception, in the Java Virtual Machine specification, there are two exceptions to the virtual machine stack: If the thread requests a stack depth greater than the virtual machine allows, the STACKOVERFLOWERROR exception will be thrown, and if the virtual machine stack can be dynamically extended (most of the current Java virtual machines can be dynamically extended, However, a fixed-length virtual machine stack is also allowed in the Java Virtual Machine specification, which throws a OutOfMemoryError exception when the extension fails to request enough memory.
Allocate on Stack, the basic idea is that for those objects that are private to the thread (objects that cannot be accessed by other threads), they can be scattered on the stack instead of allocated on the heap. The benefit of allocating on the stack is that it can be destroyed at the end of the function call, without the need for the garbage collector to improve the performance of the system. The allocation on the stack relies on the implementation of escape analysis (-xx:+doescapeanalysis) and scalar substitution (-xx:+eliminateallocations, which opens by default, allowing objects to be scattered across the stack).
The local method stack local method stack (Native methodstacks) is very similar to the virtual machine stack, except that the virtual machine stack executes Java methods (that is, bytecode) services for the virtual machine, while the local method stack serves the Native method used by the virtual machine. The language, usage, and data structure of the methods used in the local method stack in the virtual machine specification are not mandatory, so the virtual machine can implement it freely. Even some virtual machines, such as sun HotSpot virtual machines, combine the local method stack and the virtual machine stack directly.
As with virtual machine stacks, the local method stack area throws Stackoverflowerror and OutOfMemoryError exceptions.
JavaHeapA heap is the largest piece of memory managed by a Java virtual machine. The Java heap is a piece of memory that is shared by all threads and created when the virtual machine is started. The only purpose of this area of memory is to hold object instances where almost all of the object instances are allocated memory. However, with the development of JIT compiler and the gradual maturation of escape analysis technology, stack allocation, scalar substitution optimization technology will lead to some subtle changes, all the objects are allocated on the heap and gradually become less "absolute".
Heaps are the main areas of garbage collector management, so they are often called "GC heaps".
The size of the heap can be set by the-XMS (minimum) and-xmx (maximum) parameters,-xms the minimum memory requested when the JVM starts, defaults to 1/64 of the operating system's physical memory, but less than 1G,-XMX is the maximum memory that the JVM can request, and defaults to 1/4 but less than 1G of physical memory. By default, when the free heap memory is less than 40%, the JVM increases the size specified by the heap to-XMX, which can be specified by-xx:minheapfreeration=, and when the free heap memory is greater than 70%, the JVM reduces the size of the heap to the size specified by-XMS. This comparison column can be specified by xx:maxheapfreeration=, and for running systems, to avoid frequent resizing of the heap at run time, the-XMS is usually set to the same value as-XMX.
If from the perspective of memory recycling, because modern collectors are basically the generation of collection algorithm, so the Java heap can be subdivided into: the new generation and the old age;
New generation: The newly created object of the program is the allocation of memory from the Cenozoic, the Cenozoic by Eden Space and two blocks of the same size survivor space (usually called S0 and S1 or from and to), you can specify the size of the Cenozoic by the-XMN parameter, or through the-XX: Survivorration to adjust the size of Eden Space and Survivorspace.
Old age: Used to store after a number of Cenozoic GC still survive objects, such as cache objects, new objects may also be directly into the old age, there are two main cases: 1, large objects, can be set by the start parameter-xx:pretenuresizethreshold=1024 (in bytes, The default is 0) to represent when more than the new generation is not allocated, but directly in the old age distribution. 2, a large Array object, and no external objects are referenced in the array.
Older generations accounted for the memory size of-xmx corresponding to the value minus-xmn corresponding value.
A OutOfMemoryError exception will be thrown if there is no memory in the heap to complete the instance assignment and the heap can no longer be expanded.

Method area in JDK 1.6, JDK 1.7, the method area can be understood as a permanent zone (Perm, can be specified using Parameters-xx:permsize and-xx:maxpermsize). In JDK 1.8, the permanent zone has been removed and replaced by the metadata area (-xx:maxmetaspacesize specified). Inside a JVM instance, type information is stored in a memory logical area called the method area. Type information is extracted from the. class file by the ClassLoader when the class is loaded. Class (Static) variables are also stored in the method area.
Simply say the method area is used to store the type of metadata information, a. class file is the representation of a class before it is used by a Java virtual machine, and once the class is used, the Java Virtual machine mounts, connects (validates, prepares, parses), and initializes it. The result of the load is that the. class file is transformed into a specific data structure in the method area. This data structure stores the following information:
Type InformationFully qualified name of the type, the fully qualified name of the direct superclass of the type, whether the type is a class type or an interface type, an access modifier of type, an ordered list of fully qualified names for any direct hyper-interfaces
Field InformationField name, field type, modifier for field
method InformationMethod Name, method return type, number and type of method arguments (in order), modifier of method
Additional InformationAll class (static) variables except constants, a pointer to ClassLoader, a pointer to a class object, Chang (constant data and reference to other types of symbols)
The JVM maintains a constant pool for each type that is loaded. A constant pool is an ordered set of constants used by this type, including actual constants (String,integer, and floating point constants) and symbolic references to types, fields, and methods. A data item in a pool is accessed through an index, just like an array item. The metadata for each class, whether it is building an instance of this class or invoking a method of an object of that class, accesses the metadata of the method area.
When building an object, the JVM allocates space to the object in the heap, which is used to store the current object instance properties and the instance properties of its parent class (which are obtained from the method area), noting that this is not just allocating space for the instance properties of the current object, but also assigning an instance property to the parent class. That is, when a subclass of the parent class is instantiated, the JVM also constructs an object of the parent class. This problem can also be confirmed from another perspective: when invoking the constructor of the current class, the constructor of its parent class is called until object, and the invocation of the constructor method means the creation of the instance, so the parent class is definitely instantiated when the subclass is instantiated.
A class variable is shared by all instances of the class, and you can access it even when there is no class instance. These variables are only related to classes, so in the method area they become part of the logic of the class data. Before a JVM uses a class, it must allocate space for each non-final class variable in the method area.
The method area mainly has the following characteristics:
1, the method area is thread-safe. Since all threads share the method area, data access in the method area must be designed to be thread-safe. For example, if two threads are attempting to access the same class in the method area, and the class is not loaded into the JVM, then only one thread is allowed to load it, while the other threads must wait.
2, the size of the method area does not have to be fixed, the JVM can be adjusted dynamically according to the application needs. At the same time, the method area is not necessarily contiguous, and the method area can be allocated freely in a heap (even the JVM's own heap).
3, the method area can also be garbage collection, when a class is not used (not reachable), the JVM will unload this class, garbage collection.
You can limit the size of the method area through the-xx:permsize and-xx:maxpermsize parameters.
For developers who are accustomed to developing and deploying programs on a hotspot virtual machine, many people are willing to call the method area "permanent generation" (permanentgeneration), which is essentially not equivalent, just because the design team of the hotspot virtual machine chooses to put the GC The generational collection is extended to the method area, or the method area is implemented using a permanent generation. For other virtual machines (such as Bea JRockit, IBM J9, etc.) there is no concept of a permanent generation.
The garbage collection behavior is relatively rare in this area, but it is not the data that enters the method area as "permanent" as the name of the permanent generation. The memory recovery target for this area is primarily for the collection of constant pools and for unloading types.
The OutOfMemoryError exception is thrown when the method area does not meet the memory allocation requirements.
Direct Memory Direct memory is not part of the data area when the virtual machine is running, nor is it an area of memory defined in the Java VM specification. However, this part of memory is also used frequently, and may cause outofmemoryerror exceptions.
The newly added NiO class in JDK 1.4 introduces a channel-and buffer-based IO approach that allocates out-of-heap memory directly using the native library, and then operates through a Directbytebuffer object stored in the Java heap as a reference to this block of memory. This can significantly improve performance in some scenarios because it avoids copying data back and forth in the Java heap and native heap.
Java's NIO library allows Java programs to use direct memory. Direct memory is the memory interval that is applied directly to the system outside of the Java heap. In general, accessing direct memory is faster than the Java heap, but allocating memory is less efficient than the latter.
Direct memory is suitable for applications where there is less application times and more frequent visits. It is not appropriate to use direct memory if the memory space itself requires frequent application.

Summarize
Name Characteristics Role Configuration parameters Abnormal
Program
Counter

Small memory footprint, thread-private,

Life cycle is the same as thread

Approximate byte-code line number indicator No No
Virtual Machine Stack

Thread private, life cycle and thread

Same, use contiguous memory space

the memory model that the Java method executes, storing local variables

tables, Operation Stack, dynamic links, method exits and other information

-xss

Stackoverflowerror

OutOfMemoryError

Java Heap

Thread sharing, life cycle and virtual machine phase

The same, you can not use a contiguous memory address

Save object instances, all object instances (including

Array) are allocated on the heap

-xms min

-xmx Max

-xmn Cenozoic

OutOfMemoryError
Method area Thread sharing, life cycle and virtual machine phase
The same, you can not use a contiguous memory address

Stores the class information that has been loaded by the virtual machine, constants, static

Data such as the state variable, the immediate compiler compiled code, etc.

-xx:permsize:16m

-xx:maxpermsize:64m

OutOfMemoryError

Run-time
Constant pool

before JDK1.6 is part of the method area,

JDK1.7 is moved to the heap management, with dynamic

storing literal and symbolic references

HotSpotVirtual Machine ObjectsWhen an object creates a virtual opportunity to a new directive, it first checks to see if the parameter of the directive is able to locate the symbolic reference of a class in the constant pool, and checks whether the class represented by the symbol reference has been loaded, parsed, and initialized. If not, you must first perform the appropriate class loading process.
After the class load check passes, the virtual machine then allocates memory for the new object. The size of the memory required for an object is fully determined after the class is loaded. Whether or not the Java heap is structured is determined by the use of the garbage collector with the compression finishing function. Even if the pointer's mobile class allocates memory, it needs to be synchronized, in fact the virtual machine uses CAs with the failed retry method to ensure the atomicity of the update operation. The other is that the memory allocation action is divided into different spaces by thread, that is, each thread pre-allocates a small chunk of memory in the Java heap, called the local thread allocation buffer.
memory allocation Process
1. The JVM tries to initialize an area of memory in Eden space for the relevant Java object.
2. When the Eden space is sufficient, the memory request ends; otherwise to the next step.
3. The JVM attempts to release all inactive objects in Eden (this is a 1 or more advanced garbage collection). If Eden space is still insufficient to fit into the new object after release, an attempt is made to put some of the active objects in Eden into the survivor area.
4. The survivor area is used as an intermediate swap area for Eden and old, and when the old area is sufficiently large, the objects in the Survivor area will be moved to the old area, otherwise they will be kept in the survivor area.
5, when the old area is not enough space, the JVM will be in the old area of full garbage collection (level 0).
6, after the complete garbage collection, if the survivor and old areas still cannot store some of the objects copied from Eden, causing the JVM to be unable to create a memory area for the new object in the Eden area, a "outofmemory" error occurs.
After the memory allocation is complete, the virtual machine needs to initialize the allocated memory space to a value of 0. The Guaranteed instance field of an object can be used directly in Java code without assigning an initial value.
Next, the virtual machines make the necessary settings for the object. For example, this object is the instance of which class, how to find the metadata information of the class, the object's hash code, the object's GC generational age, and so on.
Finally, after executing the new command, the <init> method is followed and the object is initialized as the programmer wishes.
Memory allocation Policy
1. Priority in Eden allocation
In most cases, objects are allocated in the Cenozoic Eden region. When the Eden Zone does not have enough space to allocate, the virtual machine initiates a minor GC. Minor the GC, the surviving objects are moved to the first survivor area, and the Eden area is cleared, and once the Eden area does not have enough space to allocate, the Minor GC is launched again, and the Eden Zone and the first survivor area are garbage collected. And move the surviving objects to the second survivor area while clearing the Eden and first survivor areas.
New Generation GC (Minor GC): Refers to the garbage collection action occurring in the Cenozoic, because most Java objects have the characteristics of being born and going out, so the Minor GC is very frequent, and the general recovery speed is relatively fast.
Old age GC (Major gc/full GC): Refers to the GC, which occurred in the old age, Major GC, often accompanied by at least one minor GC (but also not absolute, in the parallel scavenge collector's mobile strategy is directly Major GC's policy selection process). Major GC speeds are generally 10 times times slower than minor GC.
2. Large objects directly into the old age
A large object is a Java object that requires a lot of contiguous memory space, and the most typical large object is the kind of string and its array that is grown up.
3. Long-term survival of the target will enter the old age
The virtual machine defines an object age counter for each object. If the Eden is still alive after the first minor GC and can be accommodated by survivor, it will be moved to survivor space and the object age is set to 1. Objects in the Survivor area each "through" a minor GC, age increased by 1 years, when its age increased to a certain extent (by default 15 years old), will be promoted to the old age.
4. Dynamic Object Age judgment
In order to better adapt to the memory status of different programs, virtual machines do not always require the age of the object must reach maxtenuringthreshold to promote the old age, if the same age in Survivor space the sum of all objects is greater than the general size of survivor space, Objects older than or equal to that age can enter the old age without waiting for the age required by the maxtenuringthreshold.
5. Space Allocation Guarantee
Before the minor GC occurs, the virtual opportunity checks whether the largest available contiguous space in the old age is greater than the total space of all new generation objects, and if this condition is true, then the minor GC can ensure that it is safe. If not, the virtual opportunity to see if the Handlepromotionfailure setting value allows the warranty to fail. If allowed, then will continue to check whether the largest available continuous space in the old age is greater than the average size of the previous promotion to the old age object, if greater than, will try to do a minor GC, although this time the minor GC is risky; or the Handlepromotionfailure setting does not allow for adventure, that is also to be done with a full GC instead. Memory layout of objects in a hotspot virtual machine, the memory layout of an object can be divided into 3 blocks: object header, instance data, and alignment padding.
The object header consists of two parts: the first part is used to store the object's own runtime data, such as hash code, GC generational age, lock status flag, thread-held lock, biased thread ID, biased timestamp, etc. The second part is the type pointer, the pointer to its class metadata, which the virtual machine uses to determine which class the object is an instance of.
Instance data is a valid information that an object actually stores, that is, the various types of field content defined in the program.
The alignment padding is due to the automatic memory management system of the hotspot, which requires that the object start address must be an integer multiple of 8 bytes. If the object instance data part is not aligned, you need to complement it by aligning the fill.
Access positioning of objects

Object access is ubiquitous in the Java language and is the most common program behavior, but even the simplest accesses involve the association between the three most important memory areas of the Java stack, the Java heap, and the method area, as in the following code:
Object obj = new Object ();
Assuming that this code appears in the method body, the semantics of the part "Object obj" will be reflected in the local variable table of the Java stack as a reference type data. The semantics of the section "New Object ()" will be reflected in the Java heap, forming a piece of structured memory that stores all instance data values of type object (Instance data, each instance field in the object). The length of the memory is not fixed, depending on the type and the object memory layout that the virtual machine implements. Also, in the Java heap, you must include address information that can find data for this object type, such as Object types, parent classes, implemented interfaces, methods, and so on, which are stored in the method area.
Because the reference type only specifies a reference to the object in the Java Virtual Machine specification, and does not define the way in which the reference should be located, and the specific location of the objects in the Java heap, the object access methods implemented by different virtual machines will vary. There are two ways to access the mainstream: using handles and direct pointers.
If you use handle access, the Java heap will divide a chunk of memory as a handle pool, where the handle address of the object is stored in the reference, and the handle contains the specific address information for the object instance data and type data.

In the case of pointer access, the layout of theJava Heap object must consider how to place information about the access type data, and The object address is stored directly in reference.

OOMExceptionjava Heap OverflowSetting the Java heap size to a smaller value (-XMS and-XMX), creating objects constantly, and ensuring that the GC roots to an object with an accessible path to avoid the garbage collection mechanism from clearing these objects, will result in a memory overflow exception. To solve the anomaly in this area, it is generally analyzed by dump, with the focus on confirming that the objects in memory are necessary, that is, whether there is a memory leak or a memory overflow in the first step.
In the case of a memory leak, further tools can be used to view the reference chain of the leaked object to the GC roots. You can then find out what path the compromised object is associated with GC roots and cause the garbage collector to not automatically reclaim them.
If there is no leakage, that is, the object in memory must still exist, then you should check the virtual machine's heap parameters, and machine physical memory to see if it can be larger, from the code to check if there are some object life cycle is too long, hold the state for too long, try to reduce the memory consumption of the program run time.

Virtual machine stack and local method stack Overflow

For a hotspot, the stack capacity is only set by the-XSS parameter. A Stackoverflowerror exception is thrown if the thread requests a stack depth greater than the maximum allowed by the virtual machine, and throws a OutOfMemoryError exception if the virtual machine cannot request enough memory space on the scale stack.
The set parameter-XSS is relatively small, and the stackoverflowerror exception can be generated by recursive invocation. Under a single thread, either because the stack frame is too large or the virtual machine stack is too small, the virtual machine throws a Stackoutofmemoryerror exception when the memory is not allocated.
It is possible to create a memory overflow exception by constantly building threads. The larger the memory allocated for each thread's stack, the more likely it is to produce a memory overflow exception. Because the system allocates memory for each process is limited, and the virtual machine provides parameters to control the Java heap and the method area of the two parts of memory maximum, the remaining memory is the maximum process memory-xmx (maximum heap capacity)-maxpermsize (maximum method area capacity), the program counter consumes memory can be ignored.
Generally speaking, stackoverflowerror exceptions do not occur (the default stack depth is sufficient in most cases), and even if this occurs, you can find the problem by the error stack that occurred.

Method area and run-time-constant pool overflow

In JDK 1.6 and earlier, the constant pool is allocated in the permanent generation (within the method area), and we can indirectly limit the capacity of the constant pool by setting the-xx:permsize and-xx:maxpermsize limit methods to size. An Oom exception can be generated by the string.valueof (i++) Intern () method. Using JDK 1.7 to run the same code will not get the same result. Because from 1.7 onwards gradually "to permanent generation".
The Intern () method in JDK 1.6 copies the first encountered string instance to a permanent generation and returns a reference to the string instance in the permanent generation. The Intern () method in JDK1.7 no longer replicates the instance, only the reference to the first occurrence of the instance is recorded in the constant pool.
JDK 1.6 outputs false, and JDK 1.7 outputs true;
String str1 = new StringBuilder ("abc"). Append ("Def"). ToString ();
System.out.println (str1.intern () = = str1);
A method area that holds class-related information such as class name, access modifier, Chang, field description, method description, and so on. For the test of the method area, the basic idea is that the runtime generates a large number of classes to fill the method area until it overflows.

Native Direct Memory Overflow

The directmemory capacity can be specified by-xx:maxdirectmemorysize and, if not specified, defaults to the Java heap Maximum (-XMX). You can get an unsafe instance by reflection to allocate memory to throw an Oom exception. A memory overflow caused by directmemory, an obvious feature of which is that there is no visible exception in the heap dump file. If you find that the dump file is small after an oom, and the program uses NIO directly or indirectly, consider checking that it is not a direct memory overflow.

Memory overflow and memory leak memory overflow out of memory, which means that the program does not have enough memory space for it to use when it is requesting it, and that it is out of memory; for example, an integer is applied, but a long can be stored to save it.
Memory leak memories leak, refers to the program after the application of memory, can not release the requested memory space, a memory leak damage may be ignored, but the memory leak accumulation of serious consequences, no matter how much memory, sooner or later will be occupied.
Memory leak will eventually result in out Ofmemory.
The outofmemoryerror exception for Java heap memory is the most common memory overflow exception in practical applications. When a Java heap memory overflow occurs, the exception stack information "Java.lang.OutOfMemoryError" is followed by a further hint of "Java heapspace".
To solve the anomaly in this area, the general approach is to first analyze the dump-dump snapshot through a Memory image analysis tool (such as Eclipse Memory Analyzer), with a focus on verifying that the objects in memory are necessary. That is, the first to know whether there is a memory leak (memories Leak) or memory overflow (Overflow).
In the case of a memory leak, further tools can be used to view the reference chain of the leaking object to the GC Roots. You can then find out what path the leak is associated with GC Roots and cause the garbage collector to not automatically reclaim them. Having mastered the type information of the leaking object, as well as the information of the GC Roots reference chain, the location of the leak code can be more accurately located.
If there is no leak, in other words, the objects in memory must still exist, then you should check the virtual machine's heap parameters (-xmx and-XMS), and the machine physical memory to see if it can be larger, from the code to check if there are some object life cycle is too long, holding the state of the time is too long, Try to reduce the memory consumption during program run time.

Java memory area and memory overflow exception

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.