Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 88c81ae36e184d92c61efff65f4cce601ccc2fed..5410334df57a25862861a81b386e2eafd9409244 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -544,6 +544,14 @@ template <class T, class M> class Persistent { |
Copy(that); |
return *this; |
} |
+ /** |
+ * The destructor will dispose the Persistent based on the |
+ * kResetInDestructor flags in the traits class. Since not calling dispose |
+ * can result in a memory leak, it is recommended to always set this flag. |
+ */ |
+ V8_INLINE(~Persistent()) { |
+ if (M::kResetInDestructor) Reset(); |
+ } |
/** |
* If non-empty, destroy the underlying storage cell |