A buddy of mine IM’d me last night and came across an interesting behaviour in Flash. He had been trying to hunt down a memory leak in his Flash AS3 project and did a simple test using an Enter_Frame loop and traced out System.totalMemory.   His tests showed totalMemory going up just a little over time. I tested it on my side and even testing it in Flex and got the same behaviour.  It’s very small, but I was curious why this was happening.

Here is the very simple sample code in Flash CS3 (you could repeat it in Flex as well):

[code]

 addEventListener(Event.ENTER_FRAME, repeater);

function repeater(evt:Event) {
 trace("System memory:"+System.totalMemory);
}

[/code]