1. Code
  2. JavaScript

Quick Tip: Monitor Memory and CPU in Your Applications

Scroll to top
Read Time: 1 min

In this Quick Tip, we'll take a look at Hi-ReS! Stats: an easy way to display the FPS, memory usage and CPU usage of your Flash apps and games. Read on!

Step 1: Brief Overview

Hi-ReS! Stats for Flash and AS3

A third party ActionScript 3 class will be used to display the current amount of memory and cpu used by the Flash Player, this will make easier for the developer to detect memory or cpu leaks.

Step 2: Stats Class

Hi-ReS! Stats for Flash and AS3Hi-ReS! Stats for Flash and AS3Hi-ReS! Stats for Flash and AS3

The Hi-ReS! Stats class by Mr.Doob takes care of the job, you can download it on its GitHub page. You can also visit the blog post to read more about it.

Step 3: Usage

The usage couldn't be easier, just add the class to your project folder and import it using the following code:

import net.hires.debug.Stats;

Then add this line in your constructor:

addChild(new Stats());

That's it, test your movie and you'll see a rectangle filled with the information in the top-left corner of your app.

Step 4: Example

I used the class in on the final SWF of my Space Shooter Tutorial game, it shows that memory stays between 5.5 and 6.5MB (Flash Player 10.2 Mac, Standalone) so that means there's no leak!


If you are a Flash Developer then the Stats class is a must try, it is simple, powerful and really useful.

Thank you for reading!

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.