JDK-6526767 : Applet heap memory - OutOfMemoryError
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2007-02-20
  • Updated: 2010-05-07
  • Resolved: 2009-01-21
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
There is something weird going on with applet heap memory.   This first came up in the following JAI forum thread:

The reporter in that thread provided a simple applet and htm.  I modified it to display memory usage - see attached codes.   Also attached, Java console output from running this applet using JDK 1.6.0 b105 on the following environments:
 1) Windows XP (both IE and FF)
 2) Fedora Core6 Linux (32-bit, FF only)
 3) Solaris 10 (64-bit, FF only)

How to reproduce the issue
 o compile the code,
 o place the HTM and CLASS files together in a web server docs folder somewhere
 o ensure the Java Plugin has standard -Xmx64m setup, and that Java Console will open
 o open your browser (ensure Java Console is open) then navigate to the HTM file
 o once the applet finishes loading, press the browser refresh button
 o repeat the above step several times

What happens
 o when the appelt init()s it creates an array of bytes of size 55Mb
 o In the console, you'll see free/total heap memory used by the applet at each applet "lifecycle stage" (init, start, stop, destroy) as well as a list of applets in the applet context.
 o there is an OutOfMemoryError straight after the first time you try to refresh on all systems.
What is expected
 o the 55Mb array should be cleanly GC'ed after Applet/destroy() is called
 o no OutOfMemoryError
 o total heap memory shouldn't be increasing like that

EVALUATION This should be fixed via the following RFE in 6u10: 6399750 RFE: Improve applet lifecycle and LiveConnect support in Java Plug-in

EVALUATION This is likely the same cause for 6480140 : Thread leak in applets 6462598 : thread leaking in IE fast open and close of applet 6550586 : JApplet Memory Not Released When Reloading Pages We'll try to address this in an upcoming jdk 6 update release in a near future.