最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to measure memory usage and efficiency? - Stack Overflow

programmeradmin1浏览0评论

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.

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

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?

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.

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

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?

Share Improve this question edited Sep 19, 2011 at 15:34 pimvdb 155k80 gold badges311 silver badges356 bronze badges asked Sep 19, 2011 at 15:25 AndrewAndrew 239k195 gold badges530 silver badges718 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 15

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

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

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

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.

Also,

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

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

Chrome also has the "about:memory" page, but I agree with IAbstractDownVoteFactory - developer tools are the way to go!

发布评论

评论列表(0)

  1. 暂无评论