Chrome在这个“GC事件”中做了什么? [英] What is Chrome doing with this "GC Event"?

查看:472
本文介绍了Chrome在这个“GC事件”中做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从一个非常简单的网站获得以下时间表。 Chrome告诉我,它通过GC清理10MB,但我不知道它可能如何!对此的任何见解将不胜感激。





我以为这样可以让你扩大形象,但是我猜不到这里是完整的大小: http://i.imgur.com/FZJiGlH.png

解决方案

这是一个我们可以查看或是内部的网站吗?我想偷看。我在Google Developers页面上搜索下面的摘录,内存分析101


对象大小



可以保存内存一个对象以两种方式:直接由对象
本身,并隐含地通过保存对其他对象的引用,并且
从而防止它们被垃圾
收集器(GC简称为)自动处理)。



由对象本身持有的内存大小称为浅
大小。典型的JavaScript对象为其
描述保留一些内存,并存储直接值。



通常,只有数组和字符串可以具有很大的浅尺寸。
然而,字符串通常在渲染器内存中有主存储,
只会在JavaScript堆上显示一个小的包装对象。



然而,即使通过防止其他对象被
自动垃圾收集过程处理,小对象可以间接容纳大量内存
。将
释放的内存大小,当对象本身被删除时,它的依赖对象
从GC根目录无法访问,被称为保留大小。



最后一点似乎是潜在的问题。



调查内存问题



如果您愿意,您可能需要启用chrome的功能, chrome --enable-memory-info ,并在窗帘后面高峰看看Chrome可能挂起了什么。



一旦您启用了内存分析功能,Chrome就可以访问两个新的属性:

  window.performance.memory.totalJSHeapSize; //目前使用的堆内存
window.performance.memory.usedJSHeapSize; //总堆存储

此功能将在更多详细信息中覆盖 here


I'm getting the following timeline from a very simple site I'm working on. Chrome tells me it's cleaning up 10MB via the GC but I don't know how it could be! Any insight into this would be appreciated.

I thought SO would let you expand the image but I guess not - here's the full size: http://i.imgur.com/FZJiGlH.png

解决方案

Is this a site that we can check out or is it internal? I'd like to take a peek. I came across the excerpt below while googling on the Google Developers pages, Memory Analysis 101:

Object Sizes

Memory can be held by an object in two ways: directly by the object itself, and implicitly by holding references to other objects, and thus preventing them from being automatically disposed by a garbage collector (GC for short).

The size of memory that is held by the object itself is called shallow size. Typical JavaScript objects have some memory reserved for their description and for storing immediate values.

Usually, only arrays and strings can have significant shallow sizes. However, strings often have their main storage in renderer memory, exposing only a small wrapper object on the JavaScript heap.

Nevertheless, even a small object can hold a large amount of memory indirectly, by preventing other objects from being disposed by the automatic garbage collection process. The size of memory that will be freed, when the object itself is deleted, and its dependent objects made unreachable from GC roots, is called retained size.

The last bit seems to be potentially your issue.

Investigating memory issues

If you're inclined you might want to enable this feature of chrome, chrome --enable-memory-info, and take a peak behind the curtain to see what chrome is potentially getting hung up on.

Once you have Chrome running with the memory profiling enabled you’ll have access to two new properties:

window.performance.memory.totalJSHeapSize;  // currently used heap memory
window.performance.memory.usedJSHeapSize; // total heap memory

This feature is covered in more details here.

这篇关于Chrome在这个“GC事件”中做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆