Chrome HTML Page Memory Usage

元气小坏坏 提交于 2019-12-23 03:26:51

问题


I have a page which I loaded in Chrome with Timeline started, after 5th second, you can see three spikes. After 7th second page is loaded and stabilized. Looks like chrome has allocated memory but didnt garbage collect them.

On nearly 11th second (with a black mark on Image 1), I press Garbage Collect on timeline and I see all memory released down to 3 MB. After memory comes down to 3MB, my page works correctly.

My target is to find memory leaks (if there are any). But after garbage collect, memory comes down and it still runs correctly.

  1. Is there anyway to force garbage collection after page is loaded? So that on mobile devices memory will be freed automatically?
  2. On Image 2, what are these names? They dont look as used within my library (My library's name is WebAtoms), so can I just ignore them?
  3. My library WebAtoms has few objects shown in yellow color, what does that mean (Image 3)?
  4. Is there any tutorial or in depth analysis of how to understand these profiles/timelines and what do they mean?
  5. Is there any straight forward way to get information about memory leak?

Image 1

Image 2

Image 3


回答1:


You have no control on garbage collection in javascript, you can delete properties , or set null values though to hint the GC .

Garbage collection is handled differently from one browser to another since most of them have their own javascript VM. So what might be true with Chrome would not be true on a native mobile browser.

As for how to optimise code ,depends on what the code is.

Wants some tips on how to use all that mess ?

https://developers.google.com/chrome-developer-tools/docs/heap-profiling



来源:https://stackoverflow.com/questions/11503399/chrome-html-page-memory-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!