In my small built-in flash framework, I defined the ThreeDPoint class, which contains the x, y, and z coordinates for tracking my in-game objects called Actors. I also use the class to create motion vectors, which are added and combined into each frame to create a cumulative motion vector for each actor.
I made the ThreeDPoint class unchanged to support the idea that this position cannot be changed, you can only give the actor a new position, and also discourage potential programmers (me!) From changing the motion vectors onto the stack, instead of allocating a new one Vector motion to create the desired motion.
Unfortunately, performance on this system drops very quickly. Using the Flex Builder profiler, I note that I am leaking some ThreeDPoint objects (with the 26 actors I have, I should have about 30, but only 60 seconds of runtime brings me to more than 1000 such objects), and therefore That objects are so light, the actual amount of memory is pretty constant.
On the other hand, the profiler displays more than 250,000 ThreeDPoint objects, created together after 60 seconds of execution time. Now, being the way I deliberately create and discard these objects, it doesn't seem strange to me at all. But the only thing that comes to mind when viewing such a profile is that a huge number of calls to new () and GC (without explicitly calling GC) is not what kills performance, especially considering the fact that when I started, and ThreeDPoint was volatile, everything was fine. Does that seem reasonable?
package net.emptykingdom.utils
{
public class ThreeDPoint
{
public function ThreeDPoint(x:Number = 0, y:Number = 0, z:Number = 0)
{
this._x = x;
this._y = y;
this._z = z;
}
public function get X():Number { return _x; }
public function get Y():Number { return _y; }
public function get Z():Number { return _z; }
private var _x:Number = 0;
private var _y:Number = 0;
private var _z:Number = 0;
}
}
EDIT: . , , , . , - ThreeDPoint. mutable ThreeDPoint, , - . , Flex , , . .