Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q4056 How can I catch the OutOfMemoryError exception when running an applet>

irt.org | Knowledge Base | Java | Q4056 [ previous next ]

Q4056 How can I catch the OutOfMemoryError exception when running an applet>

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.

Feedback on 'Q4056 How can I catch the OutOfMemoryError exception when running an applet>'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.