Garbage Collection

Garbage Collection

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

Yes, it is possible to preserve an object from garbage collection andlive as long as an applet. To do this you merely have to create a membervariable 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 theapplet, then both the applet and the object in question will becomeeligible for garbage collection. Usually the browser runtime will maintaina special reference to an applet while it is active, preventing it frombeing garbage collected.

See also  How to Avoid Money Transfer Scams  

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist