boyofgreen Posted January 12, 2017 Share Posted January 12, 2017 I am clearing my scene entirely, where I use completely new sounds and new plans/textures. What is the proper way to do this? I'm first going through each of my planes and removing the plane and animations for each of them: item.plane.dispose(); item.animateR.reset(); item.animateX.reset(); item.animateY.reset(); and do the same for the sounds. Then I go to the scene and do the following: scene.dispose(); scene.disposeSounds(); The problem is I still see a lot of memory being used up, even after I do this and have an empty canvas on the screen. Am I missing a step or going about this wrong? Thanks, Jeff Quote Link to comment Share on other sites More sharing options...
dbawel Posted January 12, 2017 Share Posted January 12, 2017 It's a matter of clearing the canvas - which is easy - or clearing all of the elements of your scene from memory - which do you wnt to do? DB Quote Link to comment Share on other sites More sharing options...
boyofgreen Posted January 12, 2017 Author Share Posted January 12, 2017 its about memory. I can clear the canvas no problem, but I need to get the assets all out of memory thanks, jeff Quote Link to comment Share on other sites More sharing options...
dbawel Posted January 12, 2017 Share Posted January 12, 2017 You realy want to delet everything? gl.getExtension('WEBGL_lose_context').loseContext(); DB Quote Link to comment Share on other sites More sharing options...
dbawel Posted January 12, 2017 Share Posted January 12, 2017 Here's a page i found to explain further: http://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use DB Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 12, 2017 Share Posted January 12, 2017 If you want a COMPLETE wipe of the memory you'll need to dispose the engine as well because it retains all shaders and all textures (in order to load them quickly afterwards) Quote Link to comment Share on other sites More sharing options...
Temechon Posted January 12, 2017 Share Posted January 12, 2017 To complete DK answer : scene.dispose(); engine.dispose(); davrous 1 Quote Link to comment Share on other sites More sharing options...
davrous Posted January 12, 2017 Share Posted January 12, 2017 Hi Jeff, Yes, @Temechon's answer is the best one. scene.dispose() is disposing the sounds also. Quote Link to comment Share on other sites More sharing options...
jerome Posted January 12, 2017 Share Posted January 12, 2017 Three core members answering the same question in less than half a day... I find this forum is becoming a little too luxurious davrous 1 Quote Link to comment Share on other sites More sharing options...
boyofgreen Posted January 12, 2017 Author Share Posted January 12, 2017 you and me both jermoe! thanks for the answers I'll implement tonight and see that does the trick. thanks, jeff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 12, 2017 Share Posted January 12, 2017 12 hours ago, Deltakosh said: If you want a COMPLETE wipe of the memory you'll need to dispose the engine as well because it retains all shaders and all textures (in order to load them quickly afterwards) From texture perspective at least, might there be a way to clear these copies once scene is loaded, or turn caching off to begin with? Working with compressed textures for mobile devices (which share memory between CPU & Graphics cores), having to double RAM requirements (be it smaller than for image textures) could limit the number of devices that a texture intensive scene would successfully run on. It sounds like a good optimization for desktops with an actual separate GPU with its own memory, but on a SoC seems like it could be a limiting factor. Not sure on the shader side. They do not look that big. BTW, when do you need either texture or shader? Can context / GPU / graphics core run out of memory, and request the client reload it? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 12, 2017 Share Posted January 12, 2017 You can force the engine to wipe its cache with something like (not completely accurate, I did it from memory): while (engine.getLoadedTextures().length > 0) { engine._releaseTexture(engine.getLoadedTextures()[0]; } JCPalmer 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 12, 2017 Share Posted January 12, 2017 Ran though this. What is getting cached are WebGLTextures. Think these are context objects, so not a duplication. Either gl.compressedTexImage2D() or gl.texImage2D(), which actually load the data, do not reference the WebGLTexture, so looks like no double copy ends up in javascript. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 13, 2017 Share Posted January 13, 2017 First you hit alt-f4 then you throw your CPU out the window (just kidding don't do that). I was gonna add to this but then saw @Temechon handled it. 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.