Hi,
I try to dispose element from the scene to unerased the memory used
I use the Basic_view.as of away v. 4.1.6
package
{
import away3d.containers.*;
import away3d.entities.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.utils.*;
import away3d.debug.AwayStats;
import flash.display.*;
import flash.events.*;
import flash.geom.Vector3D;
public class Main extends Sprite
{
//plane texture
[Embed(source="floor_diffuse.jpg")]
public static var FloorDiffuse:Class;
//engine variables
private var _view:View3D;
//scene objects
private var _plane:Mesh;
/**
* Constructor
*/
public function Main()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//setup the view
_view = new View3D();
addChild(_view);
// srtup stat
var stats : AwayStats = new AwayStats(_view);
stats.x = stage.stageWidth - stats.width;
stats.y = stage.stageHeight - stats.height;
addChild(stats);
//setup the camera
_view.camera.z = -600;
_view.camera.y = 500;
_view.camera.lookAt(new Vector3D());
//setup the scene
setupScene();
//setup the render loop
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
stage.addEventListener(Event.RESIZE, onResize);
onResize();
// setup key event
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPressed);
}
/**
* setup the scene
*/
private function setupScene():void
{
_plane = new Mesh(new PlaneGeometry(700, 700), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse)));
_view.scene.addChild(_plane);
}
/**
* remove the scene
*/
private function removeScene():void
{
for ( var i:int, l = _plane.numChildren; i < l; i++)
{
var el:* = _plane.getChildAt(i)
trace(" _", el);
}
_plane.material.dispose();
_plane.geometry.dispose();
_view.scene.removeChild(_plane);
_plane = null;
}
/**
* Key event
*/
private function KeyPressed(event:KeyboardEvent)
{
if ( event.keyCode == 32 )
{
removeScene();
setupScene();
}
}
/**
* render loop
*/
private function _onEnterFrame(e:Event):void
{
_plane.rotationY += 1;
_view.render();
}
/**
* stage listener for resize events
*/
private function onResize(event:Event = null):void
{
_view.width = stage.stageWidth;
_view.height = stage.stageHeight;
}
}
}
On the beginng the RAM = 70.1M
I press space bar remove and add the same object RAM = 71.5M
If I press space bar again, RAM=72.9M
Please how remove object and clean the memory.
What is the best way.
Thanks for your help.