ps boon, one fast way to verify on windows:
- repeat your action 100000 times in a for lus with the taskmanager open
If the memory you use is being recollected you will see your application
eat memory and release it, eat it and release it etc if not, it will just
be hogging memory until it hangs...
quick and dirty ;)
At 02:12 AM 12/4/2005, Boon Chew wrote:
Good stuff Steven, I am glad I asked this question (and David's reply is
great).
Is there a way to verify that the onLoad is indeed orphaned in the VM
memory pool?
- boon
Steven Sacks <[EMAIL PROTECTED]> wrote: Here is something more for you
to chew on:
If you assign say an onLoad method to an object, and don't delete the onLoad
before you delete the object, the onLoad method is orphaned and since the
reference to the object is gone, it does not get cleaned up by the garbage
collector, and remains in memory with no way to get to it.
For example (AS1 code used here):
foo = new XML();
foo.onLoad = function(valid) {
if (valid) {
// xml loaded successfully
} else {
// xml load error
}
}
If you:
delete foo;
the foo.onLoad method stays in memory.
You have to
delete foo.onLoad;
delete foo;
to really get rid of foo.
Objects cannot delete themselves, nor can they call another object to delete
them because technically you're still in the same operation thread. It has
to be done independantly outside the object you're trying to delete.
The way I get around this is:
xmlHolder = {};
var id = new Date.getTime();
xmlHolder[id] = new XML();
xmlHoLDer[id].onLoad = function(valid) {
if (valid) {
// xml loaded successfully
} else {
// xml load error
}
this.complete = true;
}
I assign a complete = true property. Then, I have my own little clean up
tool running, checking for complete xml loads:
for (var o in xmlHolder) {
if(this.xmlHolder[o].complete) {
delete this.xmlHolder[o].onLoad;
delete this.xmlHolder[o];
}
}
The clean up tool is running in a separate thread therefore it can delete
other xmlHolder without issue.
HTH,
Steven
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
---------------------------------
Yahoo! Personals
Skip the bars and set-ups and start using Yahoo! Personals for free
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders