在沉重的AJAX应用程序的Firefox特定的内存增加应用程序、沉重、内存、AJAX

2023-09-10 16:38:58 作者:回眸,巴黎壹場夜雨

我困惑不解,为什么我的应用程序的内存增加如此之快在Firefox比其他浏览器。

I'm puzzled at why my app's memory increases so much faster in Firefox than other browsers.

Basicially,应用程序使用AJAX的一个体面的数额,与基本动作是加载具有HTML的平均水平,一般有大的图像职位的新集。每个职位的平均总数据量(包括加载图片)正在1MB,也许900K。使用jQuery 1.7.1。

Basicially, the app uses a decent amount of AJAX, with the basic action being to load new sets of posts that have an average level of HTML, and generally have large images. The total avg data amount per post (incl loaded images) is under 1MB, maybe 900k. Using jQuery 1.7.1.

在Chrome浏览器的内存似乎是稳定的,但在Firefox中,大约20MB的新内存使用每一个岗位负荷的结果。由于加载了很多帖子,你很快得到了1GB,甚至在内存1.4GB,而事情很快陷于停顿。

In Chrome memory seems to be stable, but in Firefox, every post load results in about 20MB of new memory use. Since a lot of posts are loaded, you quickly get to over 1GB and even 1.4GB in memory, and things quickly grind to a halt.

在Firefox中挖掘,我试图消除使用'删除'封锁和任何无关的变量。没有大的起色。然后我开始删除的功能,并且它似乎像一切使的贡献。

Digging in on Firefox, I tried to eliminate closures and any extraneous variables using 'delete'. No big improvement. I then started removing functionality, and it seemed like EVERYTHING makes a contribution.

删除工具提示,一些过​​度的重新加载FB小部​​件(每个职位的一项评论插件),我做了很大的改进,下至每个职位的10MB新内存。

Removing ToolTips, some excessive re-loading of FB widgets (one comment widget per post), I made a big improvement, down to 10MB new memory per post.

但除此之外,我不能得到低得多!基本上,如果我只是通过$。员额()加载新的HTML +图片(再次约900K),每个职位增加了〜新的8MB内存,即使新的图像具有显示:无。 (还试图禁用萤火虫)。

But beyond that, I can't get much lower! Basically, if I just load the new html + images (again about 900k ) via $.post() each post adds ~8mb of new memory, even if the new images have "display:none". (also tried disabling firebug).

这是我在内存管理的第一次尝试,但是这似乎只是一个很大的开销,而且奇怪,因为我不认为真的内存在Chrome中增加干这种事情。好像我应该得到内存的增加更符合数据加载,而不是10倍的金额! (或者根本不喜欢Chrome浏览器就好了)

This is my first attempt at memory management, but this just seems like a lot of overhead, and odd since I don't think memory really increases like that in Chrome at all. Seems like I should get memory increases more in line with the amount of data loaded, not 10X! (or none at all like in Chrome would be nice...)

这真的合理吗?在那里任何想法查找问题还是我能做些什么,以进一步减少这个问题?

Is this really reasonable? Any ideas on where to look for problems or what I can do to further minimize this problem?

谢谢!

更新

正如鲍里斯恰当观察到的,存储器增加是几乎完全是由于图像(至少80%)。但同样的存储器增加是加载的图像的多(10倍)的大小。还有一件事我学会了用一下:内存 - 如果我只是打开了一个新的空标签,记忆力下降很快,几乎所有相关的附加图像存储器消失。我猜这就是GC踢,并以此为鲍里斯猜测,现在看来,这很可能一个GC的问题?

As Boris aptly observed, the memory increase is almost entirely due to images (at least 80%). But again the memory increase is much more (10x) the size of the images loaded. One other thing I learned using about:memory - if I simply open up a new empty tab, the memory drops quickly and almost all the added image related memory disappears. I'm guessing that's GC kicking in, and thus as Boris guesses, it seems it's likely a GC issue?

如果是这样的话,我怎么可能会进行调查,为什么它没有被只在FF引发的自然?有没有方法来触发它的JS?正如我所说,我试图去通过,并删除封锁...

If that is the case, How might I investigate why it's not being triggered naturally only in FF? are there ways to trigger it in JS? As I mentioned, I tried to go through and remove closures...

另外一个想法,可以(通过jQuery)的结合事件的图像元素,而不是div的是坏?我认为jQuery的处理,所有的东西虽然。

One other thought, could binding events (via jQuery) to image elements instead of divs be bad? I thought jQuery dealt with all that stuff though.

推荐答案

我已经看到我的打的RAM 2GB

I have seen mine hit 2gb of ram

我在码头一个窗口小部件触发此命令,它被保存在一个文件中:

I have a widget in my dock which triggers this command which is saved in a file:

killall -c firefox
sleep 1
open -a Firefox
sleep 1
exit

快捷方式重设FF,并得到所有标签页回来。需要做到这一点大部分时间:) 如果没有Firebug的,我会在Chrome现在

Quick way to reset FF and get all your tabs back. Need to do this most days :) If it weren't for Firebug I'd be on Chrome by now