DezOnlyOne Posted October 27, 2015 Share Posted October 27, 2015 When swapping out meshes with large animations After a few swaps I get an OOM error. By swapping out animations I mean dispose of the previous mesh and load a new one. This was also an issue in THREE.js, but seems to be less of an issue because Babylon seems to handle files with large amounts of animations much better. However, it appears that both leave these animations in memory even after disposing of the mesh. What is the best way to dispose of a mesh with say, 20k frames of animation, and load another without getting an OOM. Thanks in advance for the help. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 27, 2015 Share Posted October 27, 2015 Might depend on the type of Animation, ANIMATIONTYPE_VECTOR3 or ANIMATIONTYPE_QUATERNION, for things like position / rotation / scale, or ANIMATIONTYPE_MATRIX for skeletal. In the case of skeletal, the mesh does not "own" the animation, it is part of the BABYLON.Skeleton object. BABYLON.Mesh.dispose() not explicitly dispose the skeleton (or anything on the CPU) , but it should not have to. If all uses / references held of the BABYLON.Animation object were to fall out of scope, then it would be a candidate for garbage collection. Remember: This IS NOT C++ where you are responsive for releasing your own memory. The VM handles that. Mesh.dispose() is only explicitly releasing resources on the GPU. If this is skeletal animation, scene.skeletons[ ] will need to splice out the reference 2 the object, so it can be garbage collected. DezOnlyOne 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 27, 2015 Share Posted October 27, 2015 I think there is something right in the question. Looking at the code, it seems like animatables stay in an array in the scene and are never disposed. They should also be stopped before the mesh is destroyed, which I don't see as well.I can push a fix (shouldn't be a problem), but I want to see if DK has a different approach. DezOnlyOne 1 Quote Link to comment Share on other sites More sharing options...
davrous Posted October 27, 2015 Share Posted October 27, 2015 Can you please share a repro somewhere? Can you please also push a repro sample with the babylon.max.js version? We're going to investigate. Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 27, 2015 Author Share Posted October 27, 2015 I will put one together in a bit. Thanks guys. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 27, 2015 Share Posted October 27, 2015 Agree with Raanan Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 27, 2015 Share Posted October 27, 2015 I'll fix it later. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 27, 2015 Share Posted October 27, 2015 I'm on it Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 27, 2015 Share Posted October 27, 2015 Do you reuse your skeletons? because else, you need to remove them from the scene as well Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 27, 2015 Author Share Posted October 27, 2015 I put together a package. I can't get the cross origin proxy site to keep working over time. So I packaged everything up into a zip file. It is too big to attach to thisforum so here is the link. There are too buttons to load one of the 2 patients. alternating between them multiple times will produce the OOP error. http://protest.jht.com/duke/babylonswap.zip Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 27, 2015 Share Posted October 27, 2015 can you check with the latest version I published on the repo? (and can you as well try to dispose skeletons if you are no more using them) Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 27, 2015 Author Share Posted October 27, 2015 Added the dispose to the removePatient() function. Still getting the OOM error. function removePatient() { if (patient) { skeletons.forEach(function(s){ s.dispose()}); meshes.forEach(function(m){ m.dispose()}); meshes = null; skeletons = null; patient = null; }} Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 28, 2015 Share Posted October 28, 2015 Can you do a memory profile using Edge or Chrome to see where the memory goes Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 28, 2015 Author Share Posted October 28, 2015 I am not totally sure how to read the memory snapshot, but it looks like the memory is tied up with Skeleton, bones, and animation. What I did was load the bigger patient, and then removed him. Disposing of skeletons and meshes. There is nothing visible on screen when I took this snapshot Attached is a screenshot of the snapshot. I can upload the actual snapshot somewhere for you to download, but it is 59MB. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 28, 2015 Share Posted October 28, 2015 If I am reading this correctly, all or a lot of the space is in the Float32Arrays backing all the Matrixs objects. The number of Matrix objects is pretty high, and is nearly identical to the number of Float32Arrays. I wonder if they might still be in scene._activeSkeletons? SmartArray.reset() called every frame does not actually make changes to SmartArray.data. Could still be there. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 28, 2015 Share Posted October 28, 2015 I've just tested with your test scene and when I call your "removePatient" function the memory seems to be freed Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 28, 2015 Author Share Posted October 28, 2015 That's odd. I used that function before I made the heap snapshot above. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 28, 2015 Share Posted October 28, 2015 I moved from 52 mb to 7mb Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 29, 2015 Author Share Posted October 29, 2015 For me the heap snapshot size was relatively low, for a couple of times alternating between loads. It starts to get bigger after several times. Eventually it will crash chrome for me. Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted November 11, 2015 Author Share Posted November 11, 2015 I am still having the same issue. I have tried everything I know how to do. It seems that there is still this residual animation information that is left behind. I tried to delete all the skeletal animations, but nothing seems to work. I am not sure how many others have similar issues to mine who has tens of thousands of frames of animations that they need to have available, but it seems like I am crossing some threshold, or ding this completely wrong. I updated my babylonswap package for an example herehttp://protest.jht.com/duke/babylonswap.zip I also uploaded it so that could be viewed online. http://protest.jht.com/duke/babylonswap/ When you load the page the app will load the patientA automatically. The problem is that in the application that I am building, I need to be able to swap files multiple times. As many times as my end user would like to. So when you click the button to load patientB, then back to A, then back to B and so on... You end up with an OOM error. This same thing was happening to me in threejs. Babylon works much better for my needs, but this one lingering issue, will make or break a HUGE project. I just need to know what I am doing wrong here. please help Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 11, 2015 Share Posted November 11, 2015 Let's work by eliminating multiple sources. Is it working when there is no animation? Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted November 11, 2015 Author Share Posted November 11, 2015 Yes. It works fine with no animation. We created a test with very high poly shapes. A teapot and a torus. Both about 180MB babylon files. There is of course a dreop in frame rate while the file loads but otherwise no OOM error. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 11, 2015 Share Posted November 11, 2015 ok so now can you do it with a single animation (like position animation) ? Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted November 11, 2015 Author Share Posted November 11, 2015 I cannot do it myself with this model, I would need the help of one of our artists, but I could create a very simple animation to try with shapes. I setup 2 files with 10000 frames of animation, and around 80k verts. I can't do skeletal animations because I don't have the know how, and the artists have gone home for the evening. The files that I did setup seem to swap fine with just an animation of their position. They were very big as well(50MB & 170MB). Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 11, 2015 Share Posted November 11, 2015 Ok so seems like the problem comes from skeletons animation So my next ask: can you animate just one single bone? If the issue appears please send me the file you used along side your code Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.