How do you free a wrapped C++ object when associated Javascript object is garbage collected in V8?

后端 未结 3 2021
攒了一身酷
攒了一身酷 2021-01-31 04:05

V8\'s documentation explains how to create a Javascript object that wraps a C++ object. The Javascript object holds on to a pointer to a C++ object instance. My question is, let

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-31 05:04

    Do all your work in some closed scope (of object or function). Then you can safely remove the C++ object when you went out of scope. GC doesn't check pointers for existence of pointed objects.

提交回复
热议问题