October 29th, 2007

Flash: Every increasing system memory

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:

  1.  addEventListener(Event.ENTER_FRAME, repeater);
  2.  
  3. function repeater(evt:Event) {
  4.  trace("System memory:"+System.totalMemory);
  5. }

2 Responses to “Flash: Every increasing system memory”

  • I would say it’s the creation of an Event object on every frame. I should be GCed eventually.

  • I’m not sure if that’s what you’re referring to, but remember system memory is the memory USED by the system, not memory available.