I’ve been trying to track down a leak in my game (which uses OpenFL 3.3.5 / Lime 2.6.4, and targets html5), and the leak appears to be coming from DisplayObjectContainer.
In the Chrome profiler, I noticed that the number of Bitmap objects in use was steadily increasing over time (from an expected ~250 up to over 950 a few minutes later). I’m pulling Bitmaps out of a sprite map to use as animation frames (these get parented to a DisplayObjectContainer on the Stage), so it makes sense that more get created over time; however, frames that are no longer needed are removed via removeChild(), and all references are nulled.
The profiler showed that most of the existing Bitmaps were in DisplayObjectContainer’s __removedChildren array. As a test, I commented out the line that adds the removed children to this array; with that change, my Bitmap count never exceeded ~250 objects.
Looking at the code, it seems that this array is only relevant when the DOMRenderer is used:
@:noCompletion @:dox(hide) public override function __renderDOM (renderSession:RenderSession):Void {
[...truncated...]
for (orphan in __removedChildren) {
if (orphan.stage == null) {
orphan.__renderDOM (renderSession);
}
}
Is there a reason removed children need the extra render pass when the DOM is used, versus, say, the Canvas? More importantly, is there a reason this array would not be getting cleaned up correctly? I see it being spliced in all the render calls (including Canvas, which is what my game is using).
Thanks for any help you can provide! =)