I thought I should share a component I whipped together for ActionScript 3 projects in Flash that allows you to easily monitor memory usage and framerate. It's simple, unobtrusive, and only adds 0.5kb to your SWF.
It's only about 5 lines of code, but it's handy to have kicking around your component panel for quick access.
Here's a simple demo of it (it's the little widget on the right). It just generates random ByteArray data to force the memory usage up and framerate down.
You can download the FLA for the above demo, and a SWC file that you can drop into your components directory by clicking here.
Follow @gskinner on Twitter for more news and views on Flash, Flex, and ActionScript.

Comments (11)
Hi,
Nice work Grant.
I released a similar set for Flash Lite developers recently. Its avaiable with source code at http://wiki.forum.nokia.com/index.php?title=Oxygen_-_The_Flash_Lite_Developers_Kit
I have included a bar-graph to show percentage of the FPS and Memory. Maybe you'd also add graphs to this component :)
// chall3ng3r //
Posted by: chall3ng3r at April 15, 2008 08:39 PMURL: http://www.orison.biz/blogs/chall3ng3r/
Useful! I've already inserted it into my project. I wish it updated the fps field a little less often though. It's flickers around so much that I can't really read it.
Posted by: Eric Smith at April 15, 2008 10:30 PMURL: http://blueflamedev.com
Thanks! Just yesterday I wasted a few minutes looking for that "fps bar widget" that nearly all papervision3d experiments have in the top left corner... couldn't find it, yours will do just fine :)
Posted by: sakri at April 16, 2008 12:51 AMURL: http://www.sakri.net/blog
Nice! Small and simple. I can really but this to good use. Thanks!
Posted by: Angel Romero at April 16, 2008 04:48 AMURL: http://flashspeaksactionscript.com
Is there a way to mmake it work in flex? I linked the swc but I can't find the classes. Thanks
Posted by: Simon at April 16, 2008 06:54 AMURL:
chall3ng3r, I considered adding some features like this, but I like the simplicity of it as is.
Eric, I might add a bit of dampening. For my purposes I preferred the immediate feedback, but I realize a lot of people will likely want it to be averaged over a few frames.
Simon, not at present, but I'll try to whip up a Flex version later today or tomorrow.
Posted by: Grant Skinner at April 16, 2008 09:27 AMURL: http://gskinner.com/blog/
Not to say one is better or worse, but i've found this tool invaluable.
Idea is the same, however it tells you the average and the current, and there's a graph that lets you watch as your memory usage creates peaks and valleys.
Also it's as simple as:
var activeGraph = new ActiveGraph();
addChild(activeGraph);
-------------
the author doesn't have a website, but you can get it from here.
http://www.kirupa.com/forum/showthread.php?t=262507
Posted by: mario gonzalez at April 18, 2008 09:25 AMURL: http://onedayitwillmake.com
Stupid question. I am just developing flash project.
Posted by: marc at April 28, 2008 02:27 PMHow can I use the provided .swc file in Flash IDE? or need to use the library symbol in the provided .fla files.
Thx,
URL: http://www.silkrt.com
"drop into your components directory"
Posted by: marc at April 28, 2008 02:54 PMsorry, just being stupid....
URL: http://www.silkrt.com
Excellent little component. Thanks.
Posted by: noponies at September 14, 2008 10:31 PMURL: http://www.blog.noponies.com
for flashdevelop :
add the memorygauge.swc to the lib folder then right click on it "add to library"
and in your app write this code :
Posted by: sebastienk at January 9, 2009 05:05 AMvar memoryLevel:MemoryGauge = new MemoryGauge();
addChild(memoryLevel);
URL: