【发布时间】:2012-12-19 11:22:54
【问题描述】:
我的网站是一个非常标准的电子商务网站,它不是一个 JS 支持的独立应用程序或任何东西,它只是一个使用 JS 来做标准东西的网站,以及一些 jquery 插件来做一些事情。
我正在尝试在我的网站上进行一些 JS 内存评估。我通过查看 Chrome 任务管理器和堆快照来完成此操作。
最初,我的网站在第一次加载时位于任务管理器上的 35MB(即 35,000K)和 40MB 之间。如果我同时打开其他网站的多个标签,这是所有标签中最大的。 如果我刷新页面,它会跳到 55-60,再次刷新会看到它跳到 65-70MB。
在工作流程中的正常页面上,它会在 45-65 之间波动(有时会在 75 之间波动,具体取决于您正在执行的操作)。在页面之间单击并执行工作流程会看到内存跃升至 85-100,并随着您继续浏览该站点而增加。
我尝试做一些事情,比如检查:
- 已检测到的节点
- 堆快照和查看增量
- amix 的 MemoryLeakChecker 检查对象的大小
我需要更深入地了解循环引用或闭包问题。
堆快照并没有透露太多,大多数顶部列表是(数组),(字符串),(系统)。快照介于 4.8MB、5.1MB、5.8MB、6.8MB 之间,并且还在增加。
结果我有几个问题:
How do I understand the different metrics between snapshot memory and task manager memoryAre there any good tutorials (apart from the ones on the Google Developers site)?How much memory is considered acceptable? Given in the task manager my site is always the highest?Do I have a memory leak? Apart from the steps I've described above (which I haven't found anything concrete from) is there any other ways I can find leaks?Can you suggest any tools apart from the Chrome Dev Tools (a lot of the tools mentioned on Google for Firefox are not compatible with the latest version, eg: Leak Monitor for FF)
附带说明,我的大部分功能都是低调操作,并且不超过 200 毫秒(基于 CPU 配置文件)。我应该瞄准什么好的基准? 200ms高吗?
【问题讨论】:
-
当您说“刷新”时,您的意思是“F5”,对吧?
标签: javascript performance memory-leaks profiling google-chrome-devtools