Yes I understand garbage collection(GC) and how it's "SUPPOSE" to work :)
However, there still remains the fact that my browser is at say 146,000K
private working set memory. Let my swf file sit there for a half hour or
more and now the working set is up to 300,000K. Refresh the page that the
swf is on and memory drops back to 146,000K. Now, turn off the mechanism
that kills the content swf and re-adds it to the main swf and viola, the
memory stays consistent at 146,000K.
So, is this code not removing the content.swf appropriately on my Timer?
Shouldn't GC be working appropriately and FF not adding additional memory?
function timerHandler(event:TimerEvent):void {
trace(this.removeChildAt(0)); // remove from display list
mLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,
onCompleteHandler); // clear from memory
mLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,
onProgressHandler); // clear from memory
mLoader.unloadAndStop();// clear from memory
mLoader = null; // clear from memory
mLoader = new Loader(); // clear from memory
startLoad();
trace("timerHandler: " + event);
}
Thanks, T
PS I've been in IT since I was a kid and yes they still do mark the sectors
with a special character. The only secure erase from a drive is to do full
format and go a step further by writing back on the drive with garbage data
many times over until your paranoid self can feel good about it. However,
ultimately physically destroying the drive is the best way =)
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kerry
Thompson
Sent: Thursday, October 01, 2009 2:06 PM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] [MEMORY LEAK]
Juan Pablo Califano wrote:
> The mere fact that the
> memory footprint grows doesn't mean there's a leak.
Juan Pablo is correct, and it's important to understand why. (If you already
understand garbage collection, you need read no further, unless you want to
check the accuracy of my description :-)
As you create objects, or even variables, the Flash player allocates
memory--this is common to most runtime engines/virtual machines, including
Shockwave, C#, Java, Visual Basic (I think), and all the way back to UCSD
Pascal.
When you delete an object, or a variable goes out of scope, that memory is
no longer needed, and the Flash player notes that it is available for
re-use. It does not, however, immediately re-use the memory--in fact, it
probably doesn't even zero it out right away. The data are still there, but
the memory is marked as available.
These memory blocks are often not contiguous--your memory looks something
like a fragmented hard disk. You have a few bytes here, a couple K bytes
there. When the Flash player's memory gets too fragmented, it does a
"garbage collection". That is, it moves currently-valid objects and
variables around to make everything contiguous (un-fragmented) again. It's
much like defragmenting your hard drive, except it is done in RAM (or
virtual RAM).
The browser is probably doing the same thing. If the user has navigated away
from your Flash page, it doesn't necessarily free that memory immediately.
In fact, it probably won't, so you can still navigate forwards and
backwards.
It's sort of like deleting a file on your disk used to be. I think it's
handled differently now, but in the bad old days, the OS would simply write
a special character into the first byte of the file. There were utilities we
used to recover accidentally deleted files--we could explore the disk, find
the data, change the first byte back to what it was supposed to be, and the
file was restored. (That's somewhat simplified, but it's the right concept).
HTH.
Cordially,
Kerry Thompson
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders