Flex Diaper

I ran a smack into possibly serious problem with AIR on Sunday. The problem was that a closed Window (mx.core.Window) was not GCing because there were about 100 references (according to Flex Builder 3 even after forced GC) to the window instance after it closed, none explicitly by my code btw. There were all references from within (children of or owned by the window) or bindings from parts of the window (all too easy to do with MXML magic like an online jailbait dating service) to my model layer.
Looking at Window.close method, all it does is tell its native window to close and remove itself from the system manager it belongs to. Hmm. Supposedly, child controls are smart enough to recognize when it's taken off the 'stage' and removing references but, apparently, it's not happening. And looking at binding implementation and generated glue code, I don't see how anyone can avoid memory leak problems with even moderately complex application lifecycle scenarios.
But then, by the time you find yourself in serious need of a diaper, you would have invested enough time to write a small mound of code and paid $700 (for FB3) to see a nice table of leaks. Gosh, all this is making me happy enough to wet my pants. What a Sunday.

Advertisements