admin管理员组

文章数量:1427810

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 plex WebGL application that requires about 100MB to 200MB of memory. While developing, I have to do a lot of refreshes and my puter 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) 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)

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?

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 plex WebGL application that requires about 100MB to 200MB of memory. While developing, I have to do a lot of refreshes and my puter 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.) 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.)

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?

Share Improve this question edited Aug 21, 2019 at 17:28 Glorfindel 22.7k13 gold badges90 silver badges120 bronze badges asked Jul 1, 2012 at 23:39 Orbiting EdenOrbiting Eden 1,51214 silver badges17 bronze badges 5
  • 2 bugs.webkit/show_bug.cgi?id=76225 – user128511 Commented Jul 2, 2012 at 16:30
  • @gman: if you answer the question, I'll give you the credit. Synopsis: WebGL uses a context that is preserved by domain and tab, irrelevant of specific page (refresh). As a result, any memory allocated to the WebGL rendering is not released for garbage collection until the user navigates away from the base domain or closes the tab. A possible fix would be to add an exit button to the application that does a quick redirect to a new domain that redirects right back. – Orbiting Eden Commented Jul 11, 2012 at 20:20
  • The bug will be fixed any day now so hopefully there will be no need for workarounds soon. There's actually a test for this in the webgl conformance tests (cvs.khronos/svn/repos/registry/trunk/public/webgl/sdk/tests/…) – user128511 Commented Jul 12, 2012 at 17:35
  • My webgl behaving the same way on page refresh is not releasing the memory. (softwareengineering.stackexchange./questions/389264/…) – Muhammad Faizan Khan Commented Mar 27, 2019 at 6:15
  • Same here, refreshing the page is still not clearing the memory used up by the process. I'm also using webGL. – skiss Commented Mar 13, 2023 at 9:51
Add a ment  | 

1 Answer 1

Reset to default 2

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 puter doesn't run any faster from having a lot of unused memory.

本文标签: javascriptbrowser refresh does not do garbage collectionStack Overflow