13

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?

pimvdb
  • 151,816
  • 78
  • 307
  • 352
Andrew
  • 227,796
  • 193
  • 515
  • 708

2 Answers2

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

enter image description here

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.

Joe
  • 80,724
  • 18
  • 127
  • 145
  • Hmm...yeah, I already started using the "Heap profiler", but couldn't figure out how to read the results. – Andrew Sep 19 '11 at 16:10
1

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

Phil
  • 1,110
  • 1
  • 9
  • 25