我正在使用 Chrome 开发工具分析 javascript 应用程序。
我发现唯一增长的内存区域是 System objects total。
我想知道我怎么能理解导致这种行为的原因,因为工具中没有显示哪些系统对象被泄露的详细信息。
我查看了应用程序分配,但随着时间的推移并没有太大变化... 当我使用时间线功能堆时,会增长超过 500mb
最佳答案
根据JSHeapSnapshot.js在 Chromium 中的实现,正如 wOxxOm 的评论中提到的,执行给定节点距离到 100000000 的比较(distances[ordinal] >= WebInspector.HeapSnapshotCommon.baseSystemDistance
,其中 WebInspector. HeapSnapshotCommon.baseSystemDistance = 100000000
),如果通过,则将大小累积到饼图的System段中。
commit最后修改此值提及,
Currently if a user object is retained by both a system-space object (e.g. a debugger) and another user object, the system object might be shown earlier in the retainers tree. This happens if its distance is smaller than distances of other retaining user objects.
The patch treats links from system-space objects to user objects with less priority, so these links are shown at the bottom of the retainers tree.
这表明 javascript 堆上的系统空间对象被调试器和浏览器的其他内部组件(V8、WebKit 等)使用。它们不受脚本分配的堆对象的直接控制。
wOxxOm 也提到过这个名字曾经是 V8 堆。也就是说,V8 分配的对象超出了执行脚本的范围。
运行分析和拍摄快照很可能也会在该类别的堆对象中执行分配,从而导致您看到随着时间的推移构建系统分配的模式。
关于javascript - chrome javascript内存分析器中的系统对象是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37150569/