11
Jul
08

Finding Memory Leaks - Memory Usage Guage

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Following on from my previous post about memory leaks I thought I would show you the code I use for spotting for memory leaks at runtime.

See below

import flash.events.*;
import flash.system.System;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;

var tf:TextField = new TextField();
tf.border = true;
tf.textColor = 0x333333
tf.background = true
tf.autoSize = TextFieldAutoSize.LEFT;
addChild(tf) 

initTimer();

function initTimer():void {
	var myTimer:Timer = new Timer(1000, 0);
	myTimer.addEventListener("timer", timerHandler1);
	myTimer.start();
}

function timerHandler1(event:TimerEvent):void {
	tf.text = String(Math.round(flash.system.System.totalMemory /1000 /1000)) + " MB \n " + String(flash.system.System.totalMemory) + " Bytes";
}

Found this useful? How about buying me a coffee - simply click here.


0 Responses to “Finding Memory Leaks - Memory Usage Guage”


  1. No Comments

Leave a Reply




Close
E-mail It