Fix context leak in ObjectLifeMonitor.
The RemoteObjectFreer class is keeping the context alive even when the window is closed. For electron applications that use sandbox, this will cause a memory leak every time a new window is created with `window.open`. Close #9191
This commit is contained in:
parent
79b02ca71e
commit
19b6ba044b
2 changed files with 1 additions and 3 deletions
|
@ -12,8 +12,7 @@ namespace atom {
|
||||||
|
|
||||||
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
|
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> target)
|
v8::Local<v8::Object> target)
|
||||||
: context_(isolate, isolate->GetCurrentContext()),
|
: target_(isolate, target),
|
||||||
target_(isolate, target),
|
|
||||||
weak_ptr_factory_(this) {
|
weak_ptr_factory_(this) {
|
||||||
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);
|
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ class ObjectLifeMonitor {
|
||||||
static void OnObjectGC(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
|
static void OnObjectGC(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
|
||||||
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
|
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
|
||||||
|
|
||||||
v8::Global<v8::Context> context_;
|
|
||||||
v8::Global<v8::Object> target_;
|
v8::Global<v8::Object> target_;
|
||||||
|
|
||||||
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_;
|
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_;
|
||||||
|
|
Loading…
Reference in a new issue