Hi all.
Investigations on a previous matter in another thread made me think also of this potential memory annoyance.
When a class is defined in Actionscript, using 'class' definitions attached to movieclips, that class definition is created and referenced from _global by the class name:
class foo
{
public function foo()
{
trace( "FOO!" );
}
public function stuff()
{
...
}
}
ends up with
_global.foo --- references ---> [Function (foo constructor)] -- "prototype" --> references [Object] -- "stuff" --> references [Function (foo stuff)]
When a movieclip is placed with this class associated, it will essentially be able to 'New' an object with foo's prototype as it's own __proto__
When the swf file defining this class is unloaded, however, the class definition still exists on global. After performing some tests I found I could delete this reference and the class definition would be released from memory if there were no outstanding references to it.
So my thought is : for a given swf that loads/unloads lots of potentially varied classes, the memory footprint of class definitions will never decrease (unless references are explicitly removed - which has it's own problems). I would have thought for a large application with a decent lifetime that this could potentially be a problem, especially on low footprint mobile architectures?
Does anybody know of a sane way of mitigating this ? Does Flash provide any functionality to perform cleanup of stale class defs ?
Bit of a kooky one, but I'm interested
Thanks !
Will.