hello,

> Objects cannot delete themselves, nor can they call another object to 
> delete
> them because technically you're still in the same operation thread.

I dont see why its problem to have object and delete object in same thread? 
Also I dont understand why function objects like onLoad which are inside 
some reference are also not freed when parent object is?! I mean if foo is 
not accessible why foo.onLoad is not freed automatically, you can not access 
it anyway, even if flash is calling it somewhere for example (onEnterFrame) 
it still should use parent object to access its children? Also, if they have 
reference counting in place, they can delete object the moment its ref count 
is zero, why wait for GC? Isnt GC responsible for deleting objects when they 
go out of scope, why call delete at all (at least for local objects, or 
objects that will anyway go out of scope)? Where can I read about all this 
stuff, I am new to this topic, and all this seems to me not very logical (I 
have lack of information)?

Thanks


"Steven Sacks" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> 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
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to