only mark handle as independent when it's a high memory user
This commit is contained in:
parent
bf92fa88b7
commit
40bd3336a5
2 changed files with 11 additions and 3 deletions
|
@ -38,6 +38,8 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
|
||||||
wrapper->SetAlignedPointerInInternalField(0, this);
|
wrapper->SetAlignedPointerInInternalField(0, this);
|
||||||
wrapper_.Reset(isolate, wrapper);
|
wrapper_.Reset(isolate, wrapper);
|
||||||
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
|
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
|
||||||
|
|
||||||
|
if (high_memory_)
|
||||||
wrapper_.MarkIndependent();
|
wrapper_.MarkIndependent();
|
||||||
|
|
||||||
// Call object._init if we have one.
|
// Call object._init if we have one.
|
||||||
|
@ -48,6 +50,12 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
|
||||||
AfterInit(isolate);
|
AfterInit(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrappableBase::MarkHighMemoryUsage() {
|
||||||
|
high_memory_ = true;
|
||||||
|
if (!wrapper_.IsEmpty())
|
||||||
|
wrapper_.MarkIndependent();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void WrappableBase::FirstWeakCallback(
|
void WrappableBase::FirstWeakCallback(
|
||||||
const v8::WeakCallbackInfo<WrappableBase>& data) {
|
const v8::WeakCallbackInfo<WrappableBase>& data) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ class WrappableBase {
|
||||||
|
|
||||||
// Marks wrapped object as high memory usage
|
// Marks wrapped object as high memory usage
|
||||||
// Deletes the wrapped object on the first round of GC callbacks
|
// Deletes the wrapped object on the first round of GC callbacks
|
||||||
void MarkHighMemoryUsage() { high_memory_ = true; }
|
virtual void MarkHighMemoryUsage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct internal::Destroyable;
|
friend struct internal::Destroyable;
|
||||||
|
|
Loading…
Reference in a new issue