Viewing Flash Player Memory Usage

While digging around the Flex 2 Langauage Reference I came across the System.totalMemory property.

According to the livedocs this gives:

The amount of memory (in bytes) currently in use by Adobe® Flash® Player.

This is a useful tool for monitoring memory usage while developing your applications and spotting memory leaks. To assist me in this for a current application I'm working on I created a very simple MemMon component. (Live Demo)

To use the component: 1. Download the MemMon.mxml component code to your system.

2. Create a new application in the same directory as the component

3. Paste in the following code with the following code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:local="*">
<local:MemMon />
</mx:Application>

4. Compile the application and enjoy.

Note: This does not report the memory for just your current application - it reports memory for the entire flash player - i.e. all open flash movies.

Comments
Marko Tomic's Gravatar Very useful indeed.

Thanks!

Marko
# Posted By Marko Tomic | 4/27/07 9:55 AM
Gernot's Gravatar I get the following error on line 20 MemMon.xml

Element type "historyPoints" must be followed by either attribute specifications, ">" or "/>".

thanks
# Posted By Gernot | 12/15/08 7:24 AM
James's Gravatar I got the same error. You have to wrap the contents of the script tag in CDATA tags.
# Posted By James | 2/21/09 11:05 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.