Tuesday, July 20, 2010

Different out of memory error reasons

Exception in thread "main": java.lang.OutOfMemoryError: Java heap space

The detail message Java heap space indicates that an object could not be allocated in the Java heap. This error does not necessarily imply a memory leak. The problem can be as simple as a configuration issue, where the specified heap size (or the default size, if not specified) is insufficient for the application.

Exception in thread "main": java.lang.OutOfMemoryError: PermGen space

The detail message PermGen space indicates that the permanent generation is full. The permanent generation is the area of the heap where class and method objects are stored. If an application loads a very large number of classes, then the size of the permanent generation might need to be increased using the -XX:MaxPermSize option.

Exception in thread "main": java.lang.OutOfMemoryError: Requested array size exceeds VM limit

Indicates that the application (or APIs used by that application) attempted to allocate an array that is larger than the heap size

Exception in thread "main": java.lang.OutOfMemoryError: request bytes for . Out of swap space?

The HotSpot VM code reports this apparent exception when an allocation from the native heap failed and the native heap might be close to exhaustion. The message indicates the size (in bytes) of the request that failed and the reason for the memory request. In most cases the part of the message is the name of a source module reporting the allocation failure, although in some cases it indicates a reason aswell. When this error message is thrown, the VM invokes the fatal error handling mechanism, that is, it generates a fatal error log file, which contains useful information about the thread, process, and system at the time of the crash. In the case of native heap exhaustion, the heap memory and memory map information in the log can be useful

The problem might not be related to the application, for example:

· The operating system is configured with insufficient swap space

· Another process on the system is consuming all memory resources

Or

· It is possible that the application failed due to a native leak, for example, if application or library code is continuously allocating memory but is not releasing it to the operating system

Exception in thread "main": java.lang.OutOfMemoryError: (Native method)

If the detail part of the error message is (Native method) and a stack trace is printed in which the top frame is a native method, then this is an indication that a native method has encountered an allocation failure. The difference between this and the previous message is that the allocation failure was detected in a JNI or native method rather than in Java VM code

No comments:

Post a Comment