I have found this on all browsers tested - IE, Firefox, Chrome and Safari on Window sand Safari on Apple.
Allegedly, a browser refresh, back button or forward link should dump the browser nodes and javascript variables and objects, etc. This appears to not be the case for WebGL. I first noticed it when developing a complex WebGL application that requires about 100MB to 200MB of memory. While developing, I have to do a lot of refreshes and my computer would start to slow down and freeze after 5-10 refreshes.
After some research I realized that this shouldn't be. The accepted solution out of a memory leak is to refresh the page which should release all javascript objects and variables and dom nodes. But take a look at the following images:
So what's the deal here? On small apps it isn't noticed, but for large WebGL apps like mine (orbitingeden.com) this is a real issue and my users are going to think the software is even more of a resource hog than it really is. The following image shows these refreshes gobbling up all of my available memory, so garbage collection is not working and / or JS and DOM objects are not being released:
(source: orbitingeden.com)
Does someone know of a trick to force the browser to do a true dump of memory? Why is all the documentation out there wrong?
As of 2019, it is not possible to explicitly or programmatically trigger garbage collection in JavaScript.
Does the garbage collector sweep stack memory? No. The garbage collector does only manage heap memory. All values on the stack are expected to be needed again when the program returns to that stack frame, so they must not be collected.
Garbage collection is a term used in computer programming to describe the process of finding and deleting objects which are no longer being referenced by other objects.
One of the points with garbage collection is that the objects are not cleaned up immediately they get unused. The garbage collector can determine for iteself when it's most convenient to do collections.
It's normal for a garbage collected system to leave some unused objects in the heap, as long as there is plenty of memory to use. A computer doesn't run any faster from having a lot of unused memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With