My basic question: Can memory leaks go unreported by System.totalMemory?
UPDATE: While the source of my performance issues was never fully verified it was likely something to do with GPU/CPU issues (as @divillysausages hypothesized) which I could not readily measure on the target system. In a bizarre and classic weird bug turn within the day of asking this question the problems seem to have been resolved. For the purposes of this Q&A I think it’s safe to say that System.totalMemory was being reported accurately.
Background: I’m developing 3 fullscreen Adobe Air 3 apps. These three apps and three VLC players are running constantly on a multi-screen Windows 7 machine. Each AIR app is full-screened on one of six 1080p screens. The AIR apps use Robotlegs 1.5.2 (with Lazy Mediation), AS3 Signals (with Relaxed Signals), and my own boilerplate shell that implements shared aspects: logger, loader, basic UI, scheduling service, configuration parser. I’ve been methodically stress testing the shell and it looks good. All three apps load data at regular intervals (let’s around 5 minutes) and update their views and automated stress tests show the loaders and parsers are memory safe even when being pummeled with updates. Very few objects get created after initialization, the apps more or less are just updating the same display objects continuously and the majority of the creation happens during startup.
Problem: After a few hours of running on the target system the render rate of the animation heavy modules suffers.
This problem is obviously layered, but I’m a little miffed as I’ve been profiling using Flash Builder Profilier and Mr Doobs Stats tool the memory usage seems to stabilize just fine during profiling (even if FB Profilier does some weird things with Strings: see my other question about Strings in FB Profilier). When the animation heavy app is started it reaches a level memory usage fairly quickly, and the animation performance is still good, then I check back a few hours later and the animations are choppy, irregular, and the apps UI is sluggish and unresponsive. The other two apps (which are running at low frame rates have no animation) seem pretty good and consume the same and more memory, respectively. Restarting the Animation App fixes the problem.
Even more context:
-
The animation heavy app modulates the stage.frameRate between 15 and 40 depending on it if it’s animating — initially I was thinking that a constant framerate would help but then I went to the trouble of making sure all the data-parsing happened before an animation was started to guard against race conditions where the animation wants to start in the middle of some kind of data processing deluge… I’m considering using a constant frame but it seems like a longshot
-
Using Greensock’s TweenMax for the animations and initially discovered a memory leak that I plugged up (a case of my own incorrect implementation) — presently the TimelineMax and TweenLite instances are the one thing that I continually create and destroy and they seem to GC just fine
-
Very little creating of new objects (basically value objects that have no event listeners and whose values are often overwritten) — no display objects are cyclically created/destroyed
-
Using Signals and Callbacks instead of Events as much as possible
-
Minimal amount of Timer instances (5-6) by sharing and reusing the Timer objects as much as possible and using them more for timing of seconds
-
Using renderMode “auto” Adobe AIR: Main Window Properties — not sure if I should change this for deploying to the Windows 7 Machine
Choppy animation sounds like it’s either the framerate, or the cpu/gpu is being blocked up so you’re rendering suffers – this can happen even when your memory is fine.
Try running your app through monocle and you’ll be able to see graphics performance and what’s going on in the background: https://prerelease.adobe.com/callout/?callid=59A4F95D908A4D2FB9F302729FD0D87F