开发者

In FLash AS3, does extending an object use more memory, even if the object's methods aren't used?

开发者 https://www.devze.com 2023-03-22 05:57 出处:网络
I am creating an object pool to cache some开发者_开发问答 recyclable objects in memory at the outset of my application in order to avoid (as much as possible) the performance issues caused by GC runni

I am creating an object pool to cache some开发者_开发问答 recyclable objects in memory at the outset of my application in order to avoid (as much as possible) the performance issues caused by GC running; if possible I'd like to minimize the memory my object pool reserves, so I'm attempting to pool generic forms of the objects (with no methods) and then casting the generic variants to more specific and complex object types which extend the generic form when I actually want them on the stage. The trouble is that to do this requires the generic variant class to import/extend MovieClip (because the more complicated objects are themselves MovieClips and make use of DisplayObject methods)-- does simply importing and/or extending a class add to the memory an object takes up when instantiated even if it never uses methods from the inherited class? It makes sense that it would, and some light profiling seems to suggest that it does, but I'm not 100% certain. About how large should an 'empty' MovieClip instance be in bytes?

thanks, CCJ


I would say no, at least not significantly. If it does a little, then it's very unlikely to present a problem to you. There is only one 'copy' of the bytecode in memory anyway, the footprint of an individual object will depend on the number and type of the properties, actual code does not come into it.

0

精彩评论

暂无评论...
验证码 换一张
取 消