Memory leak with Meshes?

Software: Away3D 3.x

Manic, Newbie
Posted: 14 January 2012 06:05 PM   Total Posts: 3

Hi I’m working on a project where I’m building a cylinder out of separate segments. The segments are subclasses of the away3d Mesh. I can create them, but I can’t seem to delete them from memory completely.

I’ve written a remove function for the segments that deletes all the faces, nulls any properties I’ve added on and then calls it’s parent ObjectContainer3D to remove itself.

The code works and the object is removed from the scene, but there’s something still referencing the instance of the Segment object and therefore it isn’t being marked for deletion by the Garbage Collector.

I tried a simpler version, just creating a subclass of Mesh with no extra code, not even anything to add faces to it and tried creating and then nulling the objects, but they still stuck around in the memory.

So are there some EventListeners still referencing them? If so, what are they? If not, how should I be deleting Meshes?

   

Manic, Newbie
Posted: 14 January 2012 08:41 PM   Total Posts: 3   [ # 1 ]

Ok, I’ve done some more fiddling, and it seems that setting geometry = null removes 3 event listeners that were referencing the Mesh, preventing it from being GC’d.

But there’s still another one, I think it’s something to do with SceneTransformChange but I’m not sure.

Does anyone have any ideas?

   

Manic, Newbie
Posted: 15 January 2012 03:21 PM   Total Posts: 3   [ # 2 ]

Ok, so I tried just creating and deleting the meshes, but not adding them as children to the ObjectContainer3D and now there’s no more memory leak! Only problem is that it’s kinda pointless as obviously that means nothing shows up!

So that narrows it down to the act of actually adding and removing children with ObjectContainer3Ds.

Is there something I’m missing regarding removeChild? Some process is still left in the memory preventing garbage collect

Is there a function I have to run to make sure that the ObjectContainer3D doesn’t maintain a reference to the removed Mesh?

   

Hector, Sr. Member
Posted: 13 October 2012 05:16 PM   Total Posts: 137   [ # 3 ]

Hi Manic,
I have a similar problem, Have you found a solution?
In Mesh.as, line 170, it has this comment:
//TODO: create effective dispose mechanism for meshs

So, it sounds like it is not well implemented yet. As you said it has to do with some material listeners not being removed. I haven’t had time to investigate it yet.

   

Miha003, Newbie
Posted: 09 November 2012 11:48 AM   Total Posts: 26   [ # 4 ]

Hi Hector,

I had similar problems. I don’t see any TODO comment in the Mesh.as class, probably I got a newer version.
Anyway, it seems that just calling dispose() on the mesh, don’t resolve the problem. You need to call mesh.geometry.dispose(). This call will actually free vertexbuffers…etc. then call mesh.dispose(); This fixed my memory problems…at least for now.

You can also call mesh.material.dispose() for the material, but if you have created a Mesh without a specific material, a default STATIC material is used, and when calling dispose on it, any subsequent calls of disposing the material will result in Null pointer problems.

Hope this helps.

   

Hector, Sr. Member
Posted: 11 November 2012 02:30 PM   Total Posts: 137   [ # 5 ]

Hi Miha003,

Unfortunately, this is Away 3.x, there is no dispose() in v3.x :(
Thanks for your help anyway, it’s good to know for my work in v4 smile
I don’t know if they will do more fixes in v3.x, but I can’t go to v4 with this project yet.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X