After some extensive research I've come to the conclusion that there's
an issue with using ownCanvas.

Wrote the following snippet to test out different scenarios:

package {
        import flash.display.BitmapData;
        import flash.filters.BlurFilter;
        import flash.system.*;
        import flash.display.Sprite;
        import flash.events.Event;
        import away3d.cameras.Camera3D;
        import away3d.containers.View3D;
        import away3d.primitives.Sphere;
        import away3d.materials.BitmapMaterial;
        import com.flashdynamix.utils.SWFProfiler;      //http://
www.lostinactionscript.com/blog/index.php/2008/10/06/as3-swf-profiler/
        public class MemTest extends Sprite {
                private var cam:Camera3D;
                private var view:View3D;
                private var items:Array = new Array();
                private var scenario:int = 0;
                /* Scenarios:
                 0 = [ no material, ownCanvas set to true on creation, 
ownCanvas not
set to false before removal, items are removed after 5 items has been
added ] = LEAK!
                 1 = [ no material, ownCanvas set to true on creation, 
ownCanvas set
to false before removal, items are removed after 5 items has been
added ] = NO LEAK
                 2 = [ bitmapmaterial, ownCanvas set to true on creation, 
ownCanvas
set to false before removal, items are removed after 1 item has been
added ] = NO LEAK
                 3 = [ bitmapmaterial, ownCanvas set to true on creation, 
ownCanvas
set to false before removal, items are removed after 5 items has been
added ] = LEAK!
                 */
                public function MemTest() {
                        init();
                }
                private function init( e:Event = null ):void {
                        if (stage) {
                                removeEventListener(Event.ADDED_TO_STAGE, init);
                                cam = new Camera3D( { zoom:5, focus:200 } );
                                view = new View3D( { camera:cam } );
                                addChild( view );
                                SWFProfiler.init(stage, this);
                                SWFProfiler.show();
                                addEventListener(Event.ENTER_FRAME, 
enterFrameHandler);
                        } else {
                                addEventListener(Event.ADDED_TO_STAGE, init);
                        }
                }
                private function enterFrameHandler( e:Event ):void {
                        if (items.length > ((scenario == 2) ? 0 : 5)) {
                                for each (var sp:Sphere in items) {
                                        view.scene.removeChild( sp );
                                        if (scenario > 0){
                                                sp.ownCanvas = false;
                                        }
                                        sp = null;
                                }
                                items = new Array();
                                System.gc();// It's weird that you need to call 
System.gc() for
garbage collection to actually kick in, haven't experienced this
behavior before.
                        } else {
                                var obj:Sphere = new Sphere();
                                if (scenario > 1){
                                        obj.material = new BitmapMaterial(new 
BitmapData(100, 100, true,
0xFFFFFFFF * Math.random()));
                                }
                                obj.radius = 10;
                                obj.ownCanvas = true;
                                obj.filters = [new BlurFilter(10, 10, 1)];
                                items.push( obj );
                                view.scene.addChild( obj );
                        }
                        view.render();
                }
        }
}

Has anyone experienced similar issues and maybe found a way around
this ?

Regard,
John

Reply via email to