my_var = null; and delete my_var; should do exactly the same thing...delete
doesn't actually delete the object, only the reference to the object. it
doesn't get removed from memory until later (when the GC feels like it)

var obj1 = {blah:"hello"};
var obj2 = obj1;

delete obj1;

trace(obj2.blah); // traces 'hello' ... the object was never deleted, only
the reference

-David R

On 2/1/06, j.c.wichman <[EMAIL PROTECTED]> wrote:
>
>
> Hi Roman,
> You describe my_var =null as being useless, but this should be enough for
> the garbage collector to come along and reclaim an object?
> With respect to the static issue, what do you mean with 'static instances'
> ?
> Could u provide an example of such an object with isn't reclaimed?
>
> Thanks,
> Hans
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Roman
> Blöth
> Sent: Wednesday, February 01, 2006 6:09 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] "clearing" variables from memory after use...
>
> dls schrieb:
> > Might be counting angels on a pin head here, but:
> >
> > if I set alot ( think hundreds) of _global variables  such as:
> > _global.state1 = Wisconsin;
> >
> > I assume they slow the performance of my player.
> > Is there a way to clear them after use?
> > (or more specifically, the ones I don't need -- I could figure out how
> > to specify that in the code....)
> Oh my, this really is a matter in Flash... Since we have often experienced
> variable's values not being cleared after use, we do the
> following:
>
> my_var = null;   // This first step probably is useless, but ALWAYS use
> DELETE!
> delete my_var;
>
> If the value contained within the variable is a movieclip, then make sure
> that this mc has an "onUnload"-handler that does the above with all
> variables and to avoid instances from floating in memory after having
> deleted, unloaded and removed them, if possible don't use static values!
>
> I have made the experience that static instances stay in memory after
> there
> is no reference to them left, since I set them all to null and then
> deleted
> them. Then, when I re-create an instance of such static stuff, it isn't
> created anew, but Flash uses the old piece that rests in memory.
>
> Maybe it's just that I don't really, really understand the concept of
> "static", but I know it can lead to unpredictable and hard-to-track
> errors.
>
>
> Best regards,
> Roman.
>
> --
>
> -------------------------------------------------------------------
> gosub communications gmbh | fredersdorfer str. 10  | 10243 berlin
> t [030] 29 66 88 81 | f [030] 29 66 88 84 | http://www.gosub.de
> -------------------------------------------------------------------
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to