I know this might seem overkill but how come this throws a strict warning?
var hi2u:int = 25;
// code
hi2u = null;
Was under the impression that variables that are nulled are subject to the GC sweep.
I know this might seem overkill but how come this throws a strict warning?
var hi2u:int = 25;
// code
hi2u = null;
Was under the impression that variables that are nulled are subject to the GC sweep.
Integers cannot be set to null. They’ll be destroyed whenever they go out of scope.
Ic, thanks.
An integer can’t have the value of NaN, if you set one to NaN it will just be set to 0 instead. Only Numbers can be NaN.
So when exactly is it considered ‘out of scope’, in your understanding?
The way I understand it… if it’s a local variable then it’s out of scope when you leave the function the variable is defined in.
If it’s a class variable then it should be destroyed whenever the instance of the class it is defined in gets garbage collected.
An integer is a relatively small size anyway. In theory it should be about the same size as a reference pointer. You’ll never get huge memory leaks or anything from integers. They shouldn’t ever prevent an object from being garbage collected either.
That’s how it works as far as I know. I’d have to know more about how the Flash Player actually works to tell you exactly what happens. Hopefully Senocular or somebody with inside knowledge could correct anything I wrong about.
Yeah, clearly integers aren’t a big deal, but it’s interesting to ponder. A class should get garbage collected when it’s not on the stage, being listened to, doing anything at all, right? All the GC stuff is not very transparent. :-/
Right. Whenever an object is not in the display list, has no event listeners and has doesn’t have a references pointing to it it should be garbage collected.
Of course it gets weirder than that since you’ve got issues with self-referencing objects, events which doesn’t stop garbage collection, etc…
There are actually two different kinds of garbage collection which are performed. It’s pretty complicated stuff.
:: Copyright KIRUPA 2024 //--