Reviewers: Yang,

Description:
Fixed a memory leak in v8 and another one in d8.

Cleaned up a few tests on the way. This CL brings us down to 5 leaks for d8.


Please review this at https://codereview.chromium.org/12223089/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/d8.cc
  M src/isolate.h
  M src/isolate.cc
  M src/v8.cc
  M test/cctest/test-api.cc
  M test/cctest/test-lockers.cc


Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 5fd99174d2309a85bc0cbb9d6a8a38c155ea49c9..ea723dc7d274bdb6a1820565e4acac0f593c23bc 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1378,6 +1378,7 @@ void Shell::OnExit() {
            "-------------+\n");
     delete [] counters;
   }
+  delete context_mutex_;
   delete counters_file_;
   delete counter_map_;
 #endif  // V8_SHARED
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index c8d9c3a4f6ce573c7f67ffa2c2dce20513841e0f..cb63b2b3bf16808a0e28d63c6cd2670c207456c6 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1548,6 +1548,14 @@ Isolate::ThreadDataTable::ThreadDataTable()
 }


+Isolate::ThreadDataTable::~ThreadDataTable() {
+  // TODO(svenpanne) The assertion below would fire if an embedder does not
+ // cleanly dispose all Isolates before disposing v8, so we are conservative
+  // and leave it out for now.
+  // ASSERT_EQ(NULL, list_);
+}
+
+
 Isolate::PerIsolateThreadData*
     Isolate::ThreadDataTable::Lookup(Isolate* isolate,
                                      ThreadId thread_id) {
@@ -1735,6 +1743,11 @@ void Isolate::TearDown() {
 }


+void Isolate::GlobalTearDown() {
+  delete thread_data_table_;
+}
+
+
 void Isolate::Deinit() {
   if (state_ == INITIALIZED) {
     TRACE_ISOLATE(deinit);
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index df70ba9efd4b4198b7ee28b94da4b60287f5c1d3..b0142bff0d9e536c259b769d6dc2ce17b1a8518a 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -470,6 +470,8 @@ class Isolate {
   // for legacy API reasons.
   void TearDown();

+  static void GlobalTearDown();
+
   bool IsDefaultIsolate() const { return this == default_isolate_; }

   // Ensures that process-wide resources and the default isolate have been
Index: src/v8.cc
diff --git a/src/v8.cc b/src/v8.cc
index 6c86d8ebbaa9cf4484057c02ad0775c99b2b3e38..1753650f25765dbe5c0a5d73a759368929c00824 100644
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -115,6 +115,7 @@ void V8::TearDown() {
   LOperand::TearDownCaches();
   ExternalReference::TearDownMathExpData();
   RegisteredExtension::UnregisterAll();
+  Isolate::GlobalTearDown();

   is_running_ = false;
   has_been_disposed_ = true;
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index a12c560a429cdb4b8dd17807d1a72c0523d01e91..f94f658f46ad045a52cb3e208331e690969e2642 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -16422,6 +16422,7 @@ TEST(IsolateDifferentContexts) {
     CHECK(v->IsNumber());
     CHECK_EQ(22, static_cast<int>(v->NumberValue()));
   }
+  isolate->Dispose();
 }

 class InitDefaultIsolateThread : public v8::internal::Thread {
Index: test/cctest/test-lockers.cc
diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc
index b0f2b622363ed107d9a6193b5f13892483fa284f..cd3754651017a23703897e920fb58d8eb83ffea8 100644
--- a/test/cctest/test-lockers.cc
+++ b/test/cctest/test-lockers.cc
@@ -289,6 +289,7 @@ TEST(IsolateNestedLocking) {
     threads.Add(new IsolateNestedLockingThread(isolate));
   }
   StartJoinAndDeleteThreads(threads);
+  isolate->Dispose();
 }


@@ -584,6 +585,7 @@ TEST(LockUnlockLockMultithreaded) {
     threads.Add(new LockUnlockLockThread(isolate, context));
   }
   StartJoinAndDeleteThreads(threads);
+  isolate->Dispose();
 }

 class LockUnlockLockDefaultIsolateThread : public JoinableThread {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to