I've included links to a test app that does nothing but
launch a window, play a sound, close window / repeat.
When application launches it uses about 20mb of memory. When
you click on the only button, it will launch a secondary window
that will simply play a wav file. (I set the volume low but you may
want to mute it :D)
After launching and closing the window several times the
memory usage goes up considerably and *never* falls back a
significant %. (I got it to about 100MB before I decided to quit
trying to increase the memory usage. Right now it's been running
w/o any user interaction since opening about 10 windows and it's
fairly stable at around 61MB (although that appears to be
increasing w/o user interaction).
Does anyone know of any methods I can use to ensure that the
memory consumed by secondary windows does not just persist forever
even after closing the window? Is there something I'm doing wrong
You can call System.gc() to force the garbage collector to
Try removing the event listeners when they aren't needed
anymore. I think it is more difficult for the gc to cleanup objects
need to be especially careful about those. It SHOULD clean them up
eventually, but it may take longer for it to figure out that those
objects are no longer in use.
You might also clear the secondaryWindow reference in the
parent document when the window closes. That reference might retard
garbage collection, too.