Another memory issue

Software: Away3D 4.x

Boyan, Newbie
Posted: 04 October 2013 07:15 AM   Total Posts: 18

Hello,

So, I need to put and remove meshes depending of user actions. It seems than event after removing the meshes from scene and setting their references to null, they remain in memory causing memory leak and crash later on. I made a simple test scene demonstrating that. The main part of the code is the following:

private function onKeyPressed(e:KeyboardEvent):void   // main code here
 
{
    
if(e.keyCode == Keyboard.Q)      // adding balls
    
{
  ballTest
.push(new Mesh(new SphereGeometry(10200200), colorMat));
  
view.scene.addChild(ballTest[ballTest.length 1]);
    
  
ballTest[ballTest.length 1].= (ballTest.length 1) * 10;  // positioning
     
}
     
else if (e.keyCode == Keyboard.W)           // removing all balls and clearing all references
     
{
        
for (var i:int 0ballTest.lengthi++)
  
{
   view
.scene.removeChild(ballTest[i]);
   
ballTest[i] null;
  
}
    
         ballTest 
= new Array();
   
}
 } 

An AS3 file is available for download - when compiled just press Q to add balls and W to remove all of them. It is visible in AwayStats window that RAM is increasing no matter if all the balls are removed from scene and their references are cleared.

What I am doing wrong…?

Thanks in advance.

 

File Attachments
BallCrashExample.as  (File Size: 3KB - Downloads: 294)
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X