http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/memleaks.html
Meaning of OutOfMemoryError
One common indication of a memory leak is the java.lang.OutOfMemoryError error. This error is thrown when there is insufficient space to allocate an object in the Java heap or in a particular area of the heap. The garbage collector cannot make any further space available to accommodate a new object, and the heap cannot be expanded further.
When the java.lang.OutOfMemoryError error is thrown, a stack trace is printed also.
A java.lang.OutOfMemoryError can also be thrown by native library code when a native allocation cannot be satisfied, for example, if swap space is low.
An early step to diagnose an OutOfMemoryError is to determine what the error means. Does it mean that the Java heap is full, or does it mean that the native heap is full? To help you answer this question, the following subsections explain some of the possible error messages, with reference to the detail part of the message:
- Exception in thread "main": java.lang.OutOfMemoryError: Java heap space
See 3.1.1 Detail Message: Java heap space. - Exception in thread "main": java.lang.OutOfMemoryError: PermGen space
See 3.1.2 Detail Message: PermGen space. - Exception in thread "main": java.lang.OutOfMemoryError: Requested array size exceeds VM limit
See 3.1.3 Detail Message: Requested array size exceeds VM limit. - Exception in thread "main": java.lang.OutOfMemoryError: request <size> bytes for <reason>. Out of swap space?
See 3.1.4 Detail Message: request <size> bytes for <reason>. Out of swap space?. - Exception in thread "main": java.lang.OutOfMemoryError: <reason> <stack trace> (Native method)
See 3.1.5 Detail Message: <reason> <stack trace> (Native method).