How do we force the browser to remove/unload an applet when the page is left? Each time the browser (IE or Netscape) loads our 50K applet, another instance is created in memory, causing the browser to eventually run out of memory resources and crash.

Andre van Dalen

The browser cannot be forced to unload an Applet, it will however call the lifetime methods of your applet: init(), start(), stop() and destroy().

  • Allocate resources in the init() method.
  • Free all allocated resources in the destroy() method.
  • Use the start() and stop() methods to handle your applet's running thread.

Make sure that in the destroy() method you set all references to null that may keep your resources alive.