Garbage collecting in AIR
At a recent project I had to make a video loop indefinitely and most importanly: seemless. I tried all kinds of different methods, including using FLV, F4V, M4V, FLVplayback component, the Video class, embedded video and a few other. The only solution that worked was (in my opinion) the most outdated one.
I setup a new SWF file in Flash Professional and imported the video to stage. I chose to create keyframes for each frame of the video, set the JPG compression rate to 100 and then exported the video as a SWF. This was the only method I could find that would make the video loop seamlessly. It solved one problem but introduced another.
As the application ran I monitored the memory usage and soon discovered that the application ate up more and more memory for each time the video looped. To solve this problem I forced the garbage collector to run each time the video completed a loop. This kept the memory usage stable and the application has now been running for about a month.
This is how you run the garbage collector:
System.gc()