Working with big images and AIR (memory issue: SOLVED!)

A couple of weeks ago I solved a big problem in an AIR application that I’m working on.
This application is an images manipulator; the most important problem when you work on a desktop application is that a user could be uses any kind of images, from 200kb to 5mb!

This problem is not easy to solve when you work with a lots of images because memory use increase a lots.

First of all I tried to use a “normal” load of an images working with Flex Image component, but every time that I load an 3MB image from a folder in my desktop, allocated memory grows up a lot! I arrive to use, with 10 images of the same dimension (3MB each one), 750MB of memory allocated for my application… that’s crazy!!! 
If you want create a batch you have so many problem to preview images and working with them.

So I find a good solution to use less memory (30 – 40MB for all AIR application) working with BitmapData class and Loader class.
I create a zip file where you can find a sample with a couple of images, download it to take a look. 

In this sample you can find 2 buttons, the first one load an image with Image component the other one load image with a class that I made to solve this problem.
When you try it, please open Task Manager (on Windows: right click in system bar) or Activity Monitor (on Mac: Applications>Utilities) and take a look at process and memory that every method use to do the same thing.

If you have any comment, suggestion or so on, please feel free to add a comment at this post or contact me directly.

Enjoy!