jquery ajax 导致 IE9 内存泄漏
我每 500 毫秒更新一次页面的值,并注意到 IE9 中存在由 jquery 的 $.ajax
方法引起的内存泄漏。
这是一个示例:
var refreshId = setInterval(refresh, 500);
function refresh() {
$.ajax('/url/object?get=theObjectNeeded');
}
在示例中,我没有对值执行任何操作,但通常它是一个 JSON
请求,我根据该请求填充值。无论哪种方式都会有内存泄漏。
我在 Firefox 4 和 IE8 上尝试了相同的代码,但没有发生泄漏。
有其他人遇到过这个问题吗?有人知道解决方案/黑客吗?我可以做的一件事是每隔几个小时刷新一次页面以释放内存,但我不想这样做。
I update a page's values every 500 milliseconds and noticed that there is a memory leak in IE9 caused by jquery's $.ajax
method.
Here's an example:
var refreshId = setInterval(refresh, 500);
function refresh() {
$.ajax('/url/object?get=theObjectNeeded');
}
In the example I'm not doing anything with the values but normally it's a JSON
request and I populate values based on that. Either way there is a memory leak.
I tried this same code with Firefox 4 and IE8 but the leak doesn't occur.
Has anyone else ran into this and does anyone know of a solution/hack? One thing that I could do is refresh the page every few hours to release memory but I don't want to have to do that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,ajax 请求的执行速度不如它们堆积起来的速度。为了防止这种情况,您可以确保一次仅发生一个刷新请求。
My guess is that the ajax requests are not being performed as quickly as they are stacked up. To prevent this, you could make sure that only one refresh request is happening at a time.