V8如何处理“大对象空间"中的对象? [英] How does V8 handle objects in "large object space"

查看:104
本文介绍了V8如何处理“大对象空间"中的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在V8 Wiki中读到,堆中有大的对象空间,GC无法移动该空间.

I've read in V8 wiki that there's large object space in heap which is not moved by GC.

大对象空间:此空间包含的对象大于其他空间的大小限制.每个对象都有自己的mmap'd内存区域.大对象永远不会被垃圾收集器移动.

Large-object-space: This space contains objects which are larger than the size limits of other spaces. Each object gets its own mmap'd region of memory. Large objects are never moved by the garbage collector.

然后V8如何处理这些对象?所以如果我有这样的物体

Then how does V8 handle that objects? So if I have object like this

function Point() {
  this.a = new Array(99999999).join("aaaaaaaaaa");
  this.b = new Array(99999999).join("aaaaaaaaaa");
  this.c = new Array(99999999).join("aaaaaaaaaa");
}
var a = new Point();

它会被移到较大的对象空间,而不会被GC清除吗?

it will be moved to large object space and never cleaned by GC?

推荐答案

(此处为V8开发人员.)Bergi的评论正确.大型对象不会移动到大型对象空间,它们是在大型对象空间中创建的.只要它们还活着,它们就不会移动.但是它们像其他任何对象一样被垃圾回收:当GC检测到它们不再存在时,内存将被释放.通常,释放死物体并不涉及移动它们.

(V8 developer here.) Bergi's comment is correct. Large objects are not moved to large object space, they are created in large object space. As long as they are alive, they are not moved. But they are garbage collected like any other object: when the GC detects that they are no longer live, the memory will be freed. In general, freeing dead objects does not involve moving them.

这篇关于V8如何处理“大对象空间"中的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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