如何测量内存使用和效率? [英] How to measure memory usage and efficiency?

查看:107
本文介绍了如何测量内存使用和效率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用大量的JavaScript,旨在无需页面重载运行不停机(天/周/月)。一个Web应用程序

I have a web app that uses a lot of JavaScript and is intended to run non-stop (for days/weeks/months) without a page reload.

不过,Chrome浏览器在几个小时后坠毁。 Safari浏览器没有崩溃经常,但它确实大大减慢。

However, Chrome is crashing after a few hours. Safari doesn't crash as often, but it does slow down considerably.

我如何检查问题是否是我的code,或者与浏览器本身?而我能做些什么来解决这些问题?

How can I check whether or not the issues are with my code, or with the browser itself? And what can I do to resolve these issues?

推荐答案

使用 Chrome开发者档案工具你能得到什么用你的CPU的快照,并得到一个内存快照。

Using Chrome Developer Profile Tools you can get a snapshot of what's using your CPU and get a memory snapshot.

取2捕捉镜头。选择这第一个并切换至对比如下图所示。

Take 2 snaps shots. Select this first one and switch to comparison as shown below

三角形列是工科数学符号三角形或改变。所以,如果你的三角洲是积极的,你是在内存中创建多个对象。我会再取一个特定的时间段后另一个快照,说5分钟。然后再比较结果。综观三角洲

The triangle column is the mathmatical symbol delta or change. So if your deltas are positive, you are creating more objects in memory. I'd would then take another snapshot after a given period of time, say 5 minutes. Then compare the results again. Looking at delta

如果您的增量是不变的,你是做在内存manageemnt一个好工作。如果是负数,你的code是干净,你使用的对象能够被正确地收集,再伟大的工作。

If your deltas are constant, you are doing an good job at memory manageemnt. If negative, your code is clean and your used objects are able to be properly collected, again a great job.

如果您的增量继续增加,你可能有内存泄漏。

If your deltas keep increasing, you probably have a memory leak.

此外,

document.getElementsByTagName('*'); // a count of all DOM elements

将是有益的,看看你是否正在稳步增加你的DOM元素。

would be useful to see if you are steadily increasing you DOM elements.

这篇关于如何测量内存使用和效率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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