From dcc93c914496fb64c7738408bcdc2f5882e0df6f Mon Sep 17 00:00:00 2001 From: "dcarney@chromium.org" Date: Tue, 10 Sep 2013 09:24:53 +0000 Subject: [PATCH] restore persistent dtor R=svenpanne@chromium.org BUG= Review URL: https://codereview.chromium.org/23581010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16606 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 8 ++++++++ test/cctest/test-api.cc | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/v8.h b/include/v8.h index 88c81ae..5410334 100644 --- a/include/v8.h +++ b/include/v8.h @@ -544,6 +544,14 @@ template 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 diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index aaac486..19f3309 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -12700,7 +12700,7 @@ TEST(CopyablePersistent) { CHECK_EQ(initial_handles + 3, globals->global_handles_count()); } // Verify autodispose -// CHECK_EQ(initial_handles, globals->global_handles_count()); + CHECK_EQ(initial_handles, globals->global_handles_count()); } -- 2.7.4