Greetings,
I have some generic code layout and I notice when I call setupLights it causes the memory usage to go up by .1M every second due to the line of code:
view.scene.addChild(lights);
Here is the whole function
private function setupLights():void{
change_text("lights");
lights = class_bMainSetupLights.returnLightSun();
view.scene.addChild(lights);
change_text("end");
class_bMainSetupLights = null;
}
Here is the class
package
{
import away3d.lights.DirectionalLight;
import away3d.lights.PointLight;
import away3d.materials.lightpickers.StaticLightPicker;
public class bMainSetupLights
{
private var _light : PointLight = null//DirectionalLight;
private var _lightPicker : StaticLightPicker = null;
public function bMainSetupLights()
{
setupLightSun();
}
private function setupLightSun():void{
//_light = new PointLight();
_light = new PointLight();
_light.y = 2500;
_light.z = -1800;
_light.x += 100;
//_light.lookAt(
_light.diffuse = 0.7;
_light.ambient = 0.1
_light.specular = 0.25
_light.castsShadows = true;
//return _light;
}
public function returnLightSun():PointLight{
return _light;
_light = null;
}
}
}
I’ve been trying to set everything to null when I’m done using it. I don’t really know what to do. Any ideas?
EDIT:
——————————————————
The line of code
_light.castsShadows = true;
Seems to cause the problem. At first I thought “well .1M isn’t a lot maybe it will stop” But it doesn’t appear to. Is this normal?
EDIT 2:
——————————————————
Continuing my program, adding more lines of code, I have run into another situation similar to above..
view.camera.rotationY += 0.1;
Causes the same memory leak to occur of .1M ram
EDIT 2B:
——————————————————
it appears any reference to view.camera inside the ‘enter frame’ function causes the second leak, not just reference to rotation.
Thanks
-B