You are here: irt.org | FAQ | Java | Q4056 [ previous next ]
Basically OutOfMemoryError is not an Exception.
class OutOfMemoryError extends VirtualMachineError { }
This Error is thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.
In Java the memory management is automatic, the allocation as well as deallocation (garbage Collection) is automatic.
Whenever the Java Virtual m/c is unable to allocate the requested memory, it calls the java garbage collection mechanism. The garbage collection mechanism in short is like this, VM keeps track of the usage of the various objects which are instantiated in the life time of the program. If it didn't find any object that is marked for garbage collection it is unable to free that memory, and there is continuous request for memory resource which the virtual m/c is unable to supply.
So to get around this problem, you can just finalize some of your objecta which are no longer required, i.e. you mark them for garbage collection.