Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Applets
Expertise: Beginner
Feb 26, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Garbage Collection

Is it possible to preserve an object from garbage collection (to live as long as the applet)?

Yes, it is possible to preserve an object from garbage collection and live as long as an applet. To do this you merely have to create a member variable in the applet that references the object you want to preserve. So long as the applet lives, it will maintain a reference to the object, which will prevent the garbage collector from reclaiming the object. However, as soon as the applet dies and no other object references the applet, then both the applet and the object in question will become eligible for garbage collection. Usually the browser runtime will maintain a special reference to an applet while it is active, preventing it from being garbage collected.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date