AS3.0 Memory monitoring
December 2nd, 2008
Hi for all. Today i have some problems with a SWF file that stop all Flash Player Plug-in. First i thought that may be total memory used for the player, well, and now? What can i do to know total memory? Ta-daaaa. Reading the Flash Help – this page – i saw the propertie System.totalMemory.
Its so simple to use it, bellow the sample:
var memoryUsed:Number = (System.totalMemory / 1024 / 1024).toFixed(2)); trace(memoryUsed);
System.totalMemory give memory used in Bytes, to converte it to MegaBytes is necessary first convert to Kbyte (x/1024) and after that convert Kbyte to MByte (y/1024).
Use .toFixed() to especify how much numbers ll be appear after dot. (eg 10.45 or 105.23)
Any idea? Post your comment. Thanks and see you soon.





December 24th, 2008 at 03:20
Hi, I’ve found this pretty useful. But you’ve got an extra paranthesis in your code, and it gives an error because System.totalMemory is a uint and you’re trying to give it to a Number.
var memoryUsed:Number = Number((System.totalMemory / 1024 / 1024).toFixed(2));
Thanks though! Very useful
December 24th, 2008 at 08:37
fitting location! nicely done!
December 24th, 2008 at 15:23
@Kevin Stubbs: Thanks for your response and for the usefull tip.