|
3pstation, Newbie
Posted: 13 April 2014 06:35 AM Total Posts: 11
Hi!
There are Main class where i have starling and PrefabProject. I use Stage3DProxy for this. This swf(it’s 3D level-map) i use in main flash . When i do dispose, how i can see, GPU memory do not release… So when this map-swf is loaded again flash player crash… Please Help
//Main Class public function My3DClass() { addEventListener(flash.events.Event.ADDED_TO_STAGE, initProxies); } private function initProxies(event:flash.events.Event = null):void { removeEventListener(flash.events.Event.ADDED_TO_STAGE, initProxies); _stage3DManager = Stage3DManager.getInstance(stage); _stage3DProxy = _stage3DManager.getFreeStage3DProxy(); _stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, initApp); _stage3DProxy.antiAlias = 2; _stage3DProxy.color = 0xFF0000; } private function initApp(event:flash.events.Event):void { _stage3DProxy.removeEventListener(Stage3DEvent.CONTEXT3D_CREATED, initApp); _prefab = new PrefabProject(); _prefab.initView(_stage3DProxy, this); addChild(_prefab); initStarling(); } private function initStarling():void { _starling = new Starling(StarlingStarsSprite, stage, _stage3DProxy.viewPort, _stage3DProxy.stage3D); _starling.addEventListener(starling.events.Event.ROOT_CREATED, starlingActivated) }
private function starlingActivated(event:starling.events.Event = null):void { _starling.removeEventListener(starling.events.Event.ROOT_CREATED, starlingActivated) _stage3DProxy.addEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame); }
private function onEnterFrame(event:flash.events.Event):void { Guys.update(); _hoverController.update(); _prefab.renderFrame(null); _starling.nextFrame(); }
public function destroy():void { _awayStates.unregisterView(_prefab.view); this.removeChild(_awayStates); _stage3DProxy.removeEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame); _prefab.destroy(); _starling.stop(); _starling.dispose(); _stage3DProxy.dispose(); AssetLibraryBundle.getInstance().removeAllAssets(true); _stage3DManager = null; this.removeChild(_prefab); try { new LocalConnection().connect('foo'); new LocalConnection().connect('foo'); } catch (e:*) {}; }
//Prefab Class public function initView(stage3DProxy:Stage3DProxy, parent:DisplayObjectContainer):void { _view = new View3D(); _view.antiAlias = 2; _view.stage3DProxy = stage3DProxy; _view.shareContext = true; _view.backgroundColor = 0xCCCCCC;
_camera = _view.camera; _camera.lens = new PerspectiveLens(48); _camera.lens.near = 10; _camera.lens.far = 550000;
_camera.x = -2636.898193359375; _camera.y = 1824.3687744140625; _camera.z = 2308.4296875;
//addChild(_view); parent.addChild(_view); }
public function destroy():void { parent.removeChild(_view); _view.dispose(); }
|
3pstation, Newbie
Posted: 13 April 2014 07:12 AM Total Posts: 11
[ # 1 ]
Ok, same in pure Away3d project…
I should dispose each material ? or view.dispose() should be enought?
(Also i tested without Guys - same result)
|
3pstation, Newbie
Posted: 13 April 2014 08:18 AM Total Posts: 11
[ # 2 ]
Can you please advice how to dispose away3d view totally from GPU
Now i created plain project with 3d scene from prefab (PrefabProject.as)
when i dispose view there and add to stage new instance of PrefabProject.as GPU memory just increase
Thank you.
|
3pstation, Newbie
Posted: 13 April 2014 08:22 AM Total Posts: 11
[ # 3 ]
|
theMightyAtom, Sr. Member
Posted: 13 April 2014 09:46 AM Total Posts: 669
[ # 4 ]
It’s quite difficult to track and understand what’s going on here.
Not sure of the internals of “PrefabProject” either.
Why is it you want to get rid of the view3D? Have you tried removing it’s contents and reusing it? Using the stage3Dproxy you are sharing a single instance of Stage3D for both Starling and Away3D (a must to get things running on mobile), but I think you would have more control by managing the assets within this instance than attempting to throw it away and create a new one. Just an idea, I don’t have any experience of trying to get rid of everything, but I do a lot of asset management and only ever run out of memory when loading too many large bitmaps at the same time.
It wouldn’t surprise me if there are assets left in memory when you simply throw the view3d away.
Good Luck!
Remember, wherever there’s a will there’s a workaround
|
3pstation, Newbie
Posted: 13 April 2014 10:19 AM Total Posts: 11
[ # 5 ]
So, why i need to do this. I have game where can be few levels. Each level is 3d scene. I load each scene when it need. Scene it’s swf file. When user complete level i call public method destroy() im Scene swf… to clean up memory.
Now i just test only my Scene.
When i call destroy what i do:
for each mesh for texture i call dispose() and after do view.dispose()
screen from scout:http://screencast.com/t/Z3651c7yOnie
How u can see regular memory have released… but GPU still there :(
|
John Brookes, Moderator
Posted: 13 April 2014 11:22 AM Total Posts: 732
[ # 6 ]
Dont dispose the view or even the scene.
I know they have dispose methods on them, but dont trust/use them.
If I was making a film, I wouldnt destroy the world(view), cameras, lights, actors, set, just to film the next scene.
Remove only what you no longer need and reuse everything else.
|
theMightyAtom, Sr. Member
Posted: 13 April 2014 11:42 AM Total Posts: 669
[ # 7 ]
That makes sense. You want to load levels as swf’s as in a traditional Flash game. Unfortunately it’s not that simple. It seems disposal of items from GPU is a mystery for most developers, but the way they found to achieve it is to clear all references to the texture and run garbage collection.
As John says, you can’t really avoid some manual asset management.
Check this thread… http://forum.starling-framework.org/topic/question-on-dispose
|
3pstation, Newbie
Posted: 13 April 2014 12:10 PM Total Posts: 11
[ # 8 ]
Thanks! will do complete cleaning and will see
|
3pstation, Newbie
Posted: 13 April 2014 02:23 PM Total Posts: 11
[ # 9 ]
Finally i get it. I dispose all items by myself and it’s work…
But there one more surprise:
If i remove listener _stage3DProxy.removeEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame); immediately then GPU still half-full.. but if i wait few frames it’s cleaned
Scout remove listener immediately : http://screencast.com/t/KFSjKLLx
And don’t remove listener : http://screencast.com/t/6mbxj9JWR5
(also i dont need to render away3d this time…)
Maybe some ideas?
Thanks
|