Chrome DevTools Profiler

Finding a memory leak in a Javascript application, I'm trying to use Chrome DevTools Profiler. Is there any detailed information describing all the records that can be found in it?

For example, after doing a simple “open home page, open another page, go back to the main page” and look at a comparison of snapshots, I can find the line “(array)” that has large objects and interests me. Opening this node, I see thousands of lines, for example ...

  • (script end of line) [] @ 89876
  • (transient array) [] @ 748323
  • (object properties) [] @ 77529
  • (map descriptors) [] @ 13823
  • (information about moving the code) [] @ 722653
  • [] @ 748003
  • (object elements) [] @ 40917

Where can I read about this?

+6
source share
1 answer

There are several different v8 internal things on the heap that cannot be accessed from javascript.

As an example (<end w370>), there is an array that has end-of-line offsets for the script. v8 needs it to set a breakpoint.

Each time you create an object, v8 does a lot of things and allocates memory for them. Watch the Lars Bak video about v8. http://www.youtube.com/watch?v=hWhMKalEicY

If you are interested in this topic, there are a number of slides and presentations about the internal functions of v8.

The easiest way to find a leak is to use the Heap Record profile. It shows you a “real time” chart with distributions.

you need to start recording, repeat your script several times, and if the code has a leak, you will see the same number of blue vertical bars on the chart. Therefore, you should stop recording and select the blue bar somewhere in the middle and see what objects it has.

the first blue bar is not interesting, because it can have selections that were made only once.

the latter is also not interesting, since it may have selections that will be released the next time you repeat your script.

Thus, the best candidate is the strip in the middle. http://www.youtube.com/watch?v=x9Jlu_h_Lyw

The most interesting are the objects created by your script.

+10
source

Source: https://habr.com/ru/post/954062/


All Articles