why world.removeObject not destroy object3D?

Started by Uncle Ray, April 24, 2015, 04:26:21 AM

Previous topic - Next topic

Uncle Ray

When i use world.removeObject(obj),and later use world.addObject(obj),the obj  is still there.

i thought removeobject() will clear object from memory,in fact i am wrong?

so,if i want to destroy obj,i just use,
obj.clearobject();
obj.clearrotation();
obj.cleartranslation();
obj=null;


is that right?

in a shorting say,if i want destroy a object3D,which method will free memory,and really set the obj clear?

EgonOlsen

#1
The object will be unloaded from GPU and CPU memory if there's no further reference in your code to it. In this example, setting it to null should do it unless there's some others reference to it. You can skip these clear....-methods though. They are just resetting the matrix.

Uncle Ray

with DDMS,set object3d to null,later memory will be freed.
but world.removeobject(obj),memory never freed.


ok,i think set to null,it was the best method to destroy Object3D.

EgonOlsen

Quote from: Uncle Ray on April 24, 2015, 11:41:25 AM
but world.removeobject(obj),memory never freed.
No. Why should it? The world is essentially a set of objects. As long as you keep a reference to an instance, nothing will be freed. That's how Java works...