stack and heap in V8 ( JavaScript)

后端 未结 3 465
-上瘾入骨i
-上瘾入骨i 2020-11-28 22:47

does V8 uses stack and heap like the JVM? if so does it put primitives on the stack and objects on the heap?

3条回答
  •  有刺的猬
    2020-11-28 23:24

    Yes, V8 uses a heap similar to JVM and most other languages. This, however, means that local variables (as a general rule) are put on the stack and objects in the heap. This may for instance not hold if a function closes over these values. As in the JVM, primitives can only be stored on the stack if they are stored in a local variable.

    As a user it is not something you would normally need to worry about.

提交回复
热议问题