Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure memory usage and efficiency?

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?

like image 376
Andrew Avatar asked Sep 19 '11 15:09

Andrew


People also ask

How do you measure memory usage?

Check Computer Memory Usage EasilyTo open up Resource Monitor, press Windows Key + R and type resmon into the search box. Resource Monitor will tell you exactly how much RAM is being used, what is using it, and allow you to sort the list of apps using it by several different categories.

What is a good memory usage percentage?

When the computer is idle it would use the amount of RAM required by system processes. So that depends on your operating system. For example it should be around 15-20% of your total memory for windows 10. Most Linux distributions use less than what windows would use, so that would be around 10% of your total memory.


2 Answers

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.

like image 129
Joe Avatar answered Sep 18 '22 13:09

Joe


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

like image 20
Phil Avatar answered Sep 22 '22 13:09

Phil