Reputation: 1311
I am novice to javascript development. I built a huge javascript application. Testing the application I used chrome dev tools and I dont know about profiling. I took a heap snapshot and I got 32mb on snapshot.
what is it(32mb) and How to know memory leaks in javascript?
How to use profiling to measure my application?
Upvotes: 0
Views: 169
Reputation: 14119
DevTools is able to show you the objects that look like a leak. The simplest and useful technique described here
With help of it people form gmail team managed to fix the leaks in gmail page.
Upvotes: 0
Reputation: 121
You can just press F12, you will get profiles option there. If you want to check the time required to complete the button click operation, just select Collect Javascript CPU
Profiles and say start. Then click on required button and then stop. You will get the detailed analysis of the click there. You can later check where you can reduce the total time taken for the operation. i.e., optimize it. You can also use developer tool in IE for the same purpose.
For optimization you can avoid unnecessary looping, store elements in variable and then use those which are required frequently in your code. etc.
You can also view the errors at the right bottom corner in chrome if any and can resolve those for optimization.
Profiles will give you the time taken by the parent function and the other functions which are called inside the parent function individually which helps to optimize each function independently.
When you start and stop the profiler for any operation like click of button, you will get the total time in seconds or milliseconds for that operation in Chrome profiles. If time is more that user acceptance time for that operation, you can modify/optimize your javascript code. If any operation is taking more than user acceptance time, that means your site is not having good performance and it needs optimization. The user acceptance time totally depends on the type of operation
Upvotes: 1