Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

javascript - How does V8 handle objects in "large object space"

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

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.

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();

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

(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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...