flash - AS2: Are functions declared in a class stored as separate instances taking up more memory on each object instantiated? -
flash - AS2: Are functions declared in a class stored as separate instances taking up more memory on each object instantiated? -
my question memory utilize , objects in actionscript 2. if have class definition:
class test1{ public function one(){trace("hello");} public function two(){trace("world");} }
and sec class definition:
class test2{ static public function one(){trace("hello");} static public function two(){trace("world");} }
and following:
var object1a = new test1(); var object1b = new test1();
var object2a = new test2(); var object2b = new test2();
is size of object1a + object1b greater size of object2a + object2b because of functions not beingness static (and perchance beingness copied each object instantiation)? not have actionscript 3 observe memory use, maybe can check how behaves in 3 if hard determine in 2.
i'm wondering if non-static fellow member functions references single prototype definitions, or if copied wholesale each function doubling memory utilize test1 vs test2. imagine treated references , overriding them changes reference different function in memory, not sure , bit of clarification.
thanks!
non static properties (alias fields, alias fellow member variables) have own re-create each object instance of class.
methods, whether static or not, exist in 1 re-create each class.
that makes sense, if think it: there's no reason re-create behaviuor doesn't change. status (variables) change.
the difference can think between static , non-static methods visibility level, non-static method "sees" object status, while static method can't because works on class level.
edit (prove):
aclassstatic.as class aclassstatic { public static function f():void { homecoming ; } public static function g():void { homecoming ; } public static function h():void { homecoming ; } } aclass.as class aclass { public function f():void { homecoming ; } public function g():void { homecoming ; } public function h():void { homecoming ; } } test.fla import aclass import aclassstatic var obj1:aclass = new aclass (); var obj2:aclassstatic = new aclassstatic (); if ( sizeof(obj1) == sizeof(obj2) ) trace("equal");
i have created 10,000 objects of aclass , measured executable occupies 6304 kbyte, while creating 10,000 aclassstatic objects needs 6284 kb. different, irrelevant.
flash memory memory-management actionscript-2
Comments
Post a Comment