user531820
user531820

Reputation: 313

Does un-initialized variables in actionscript3 suck up RAM spaces?

For example, if I have two classes called _Sub_class and MainClass

class _Sub_class{
    ...
    var test:int;
    var test2:int;
    function _Sub_class(){
        ....
    }
}

and

class MainClass{
    ...
    var test3:_Sub_class;
    ...
    //And never do: test3 = new _Sub_Class();
}

Does test3 take up the same space as when it's initialized? (i.e. when a function inside MainClass call the initialize function for the test3 variable?)

Upvotes: 0

Views: 142

Answers (2)

Cameron
Cameron

Reputation: 98746

No. Variables in ActionScript are always just references, which means they are essentially just pointers behind the scenes (probably 4 bytes each of memory use).

The object, when it's been created, will take up space in memory, but the variable you "store" the object in will remain a constant size, since it's only storing a reference to that object.

No space is reserved for the object until it's actually newed up.

Upvotes: 1

Ed Staub
Ed Staub

Reputation: 15690

No, it's just a null reference. It takes up a little space, but not nearly as much as an instance of the class would.

Upvotes: 1

Related Questions