浏览器刷新不会进行垃圾回收 [英] browser refresh does not do garbage collection

查看:158
本文介绍了浏览器刷新不会进行垃圾回收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在所有测试的浏览器上找到了这个 - IE,Firefox,Chrome和Safari在Apple的Window sand Safari上。

I have found this on all browsers tested - IE, Firefox, Chrome and Safari on Window sand Safari on Apple.

据称,浏览器刷新,转发链接应该转储浏览器节点和JavaScript变量和对象等。对于WebGL来说似乎不是这样。在开发需要大约100MB到200MB内存的复杂WebGL应用程序时,我首先注意到了这一点。在开发过程中,我必须做很多的刷新,而我的电脑会在5-10次刷新之后开始放慢速度并冻结。

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.

经过一番研究,我意识到这不应该是。内存泄漏所接受的解决方案是刷新应该释放所有JavaScript对象和变量和dom节点的页面。但是看看下面的图片:

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:

那么这里有什么交易?在小应用程序上并没有被注意到,但是对于像我这样的大型WebGL应用程序(orbitingeden.com)来说,这是一个真正的问题,我的用户将会认为该软件比其真正的资源更多。以下图片显示了这些刷新功能,使我可用的所有内存变得无聊,因此垃圾收集不起作用,和/或JS和DOM对象未被释放:

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:

http://orbitingeden.com/images/big_memory_after.png

是否有人知道一个诡计强制浏览器做一个真正的内存转储?为什么所有的文档出错?

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?

推荐答案

垃圾回收的一个要点是对象不是立即清理他们没有使用。垃圾收集器可以自己决定最方便的收集。

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.

垃圾回收系统tp是正常的,只要在堆中留下一些未使用的对象,只要有有足够的记忆使用。一台电脑没有运行任何更快的内存不足。

It's normal for a garbage collected system tp 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.

这篇关于浏览器刷新不会进行垃圾回收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆