Why does usedJSHeapSize always increase when we open Chrome with "--enable-exact-memory-info", although I did not do anything on this page?

I am experimenting with closing and garbage collection in javascript. Having memory information is really convenient. I am trying to use window.performance.memory.usedJSHeapSize, but I have no idea:

  • Why does the output keep growing even though I am not doing anything on the page?
  • Why, when I refresh the page several times, is the original result a little different? 3xxxxxx → refresh → 4xxxxxx → refresh → 6xxxxxx → 3xxxxxx - do you see the pattern? Does this mean that the garbage collector starts - say, once in 3 updates? My suspicions were confirmed by the addition gc()at boot.

If you want to play with my simple educational tool, the code is in my github .

+4
source share
1 answer

Why does the output keep growing even though I am not doing anything on the page?

If you compare heap snapshots using “heap snapshots” or record “Distribution timelines” on the “Web profiles” tab, you will see that setTimeoutonly the selected object MemoryInfois highlighted during the callback .

, var memory = window.performance.memory; getter, , . , .

enter image description here

+1

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


All Articles