away3d/away3d-core-fp11 — Issue #154: Memory Leak
Author: tcorbet
Created: 2011-10-16 09:18:54+00:00
State: open

I've spent a good deal of time over the past three days trying to determine why my application has a memory leak. I assumed it was either an error in my code or in my understanding/use of the Away3d API. So, I finally implemented a version of Connolly's MemoryTracker: http://divillysausages.com/taxonomy/term/7?page=1. Using that, and winnowing the application down to the least amount of code which demonstrates the leak, I now believe that the problem is in the Away3D code rather than mine.

Whatever tooling you use for regression tests don't seem to be visible here and I only find two Broomstick demos which call any of the dispose methods. Those don't represent any sort of stress test and they only entail the use of the dispose method at the level of the Mesh. It is probably more common that Mesh add/remove takes place in an ObjectContainer3D, but after hours of testing at that level, I found that the leak can be detected even in the simpler case of individual Mesh objects being added/removed from the scene.

So I am opening this bug. Not seeing any facilities here for attachments or file uploads. Presumably when I hit 'submit' a reference number will be assigned, so I will post the files that I have prepared over there. I hope the files will make it easy for you to witness the leak and diagnose it.

Whether it turns out to be my misuse of the API or a problem in the Away3d framework for Molehill, I hope it can be quickly fixed so that I can release my application. The use case of that application, as currently architected, requires that Mesh.dispose() works with its depth argument set to false. It is my understanding that retention of the Mesh object's SubGeometry should not result in a memory leak; it should result in better performance [from not having to recreate the Geometry for each instance] and a lower memory footprint [because there are, at any point in time, many Mesh Objects which share that common Geometry].

In my testing, unfortunately, the memory leak occurs whether with depth set true or false. My measurement tool is not fine-grained enough to tell me what the rate of leakage is in each case. You would guess that they would be different and they probably are, but the rate of memory consumption growth is very comparable whichever way the test is run.