From: Cheng Zhao Date: Tue, 29 Dec 2015 02:40:10 +0000 (+0800) Subject: Leak FunctionTemplateHandle X-Git-Tag: v0.36.3~39^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2294a5ce693d01453bdb2424ac5d0238a24f235f;p=electron.git Leak FunctionTemplateHandle They are cached through the app's lifetime, and freeing them at the right time is complicate, so just leak them. --- diff --git a/atom/common/api/atom_api_v8_util.cc b/atom/common/api/atom_api_v8_util.cc index 7b9490df..c86335ad 100644 --- a/atom/common/api/atom_api_v8_util.cc +++ b/atom/common/api/atom_api_v8_util.cc @@ -13,10 +13,21 @@ namespace { -using FunctionTemplateHandle = - v8::CopyablePersistentTraits::CopyablePersistent; +// A Persistent that can be copied and will not free itself. +template +struct LeakedPersistentTraits { + typedef v8::Persistent > LeakedPersistent; + static const bool kResetInDestructor = false; + template + static V8_INLINE void Copy(const v8::Persistent& source, + LeakedPersistent* dest) { + // do nothing, just allow copy + } +}; // The handles are leaked on purpose. +using FunctionTemplateHandle = + LeakedPersistentTraits::LeakedPersistent; std::map function_templates_; v8::Local CreateObjectWithName(v8::Isolate* isolate,