You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/07/13 20:24:32 UTC

[5/7] mesos git commit: Fixed memory leak of `gc` in `finalize()` in libprocess.

Fixed memory leak of `gc` in `finalize()` in libprocess.

Review: https://reviews.apache.org/r/45996/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/472fce7c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/472fce7c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/472fce7c

Branch: refs/heads/master
Commit: 472fce7c57644ec12c517c0d50cc23775ddabaa2
Parents: 5f92910
Author: Neil Conway <ne...@gmail.com>
Authored: Wed Jul 13 11:29:58 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Jul 13 13:21:07 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/gc.hpp |  3 ---
 3rdparty/libprocess/src/process.cpp        | 13 ++++++++++---
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/472fce7c/3rdparty/libprocess/include/process/gc.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/gc.hpp b/3rdparty/libprocess/include/process/gc.hpp
index 3ee1e3b..603bb8b 100644
--- a/3rdparty/libprocess/include/process/gc.hpp
+++ b/3rdparty/libprocess/include/process/gc.hpp
@@ -50,9 +50,6 @@ private:
   std::map<UPID, const ProcessBase*> processes;
 };
 
-
-extern PID<GarbageCollector> gc;
-
 } // namespace process {
 
 #endif // __PROCESS_GC_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/472fce7c/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 63cccab..181b27d 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -509,7 +509,7 @@ static Filter* filterer = nullptr;
 static std::recursive_mutex* filterer_mutex = new std::recursive_mutex();
 
 // Global garbage collector.
-PID<GarbageCollector> gc;
+GarbageCollector* gc = nullptr;
 
 // Global help.
 PID<Help> help;
@@ -1037,7 +1037,8 @@ bool initialize(
   //   |--authentication_manager
 
   // Create global garbage collector process.
-  gc = spawn(new GarbageCollector());
+  gc = new GarbageCollector();
+  spawn(gc);
 
   // Create global help process.
   help = spawn(new Help(delegate), true);
@@ -1097,6 +1098,12 @@ void finalize()
   delete process_manager;
   process_manager = nullptr;
 
+  // TODO(neilc): We currently don't cleanup or deallocate the
+  // socket_manager (MESOS-3910).
+
+  delete gc;
+  gc = nullptr;
+
   // The clock must be cleaned up after the `process_manager` as processes
   // may otherwise add timers after cleaning up.
   Clock::finalize();
@@ -2657,7 +2664,7 @@ UPID ProcessManager::spawn(ProcessBase* process, bool manage)
 
   // Use the garbage collector if requested.
   if (manage) {
-    dispatch(gc, &GarbageCollector::manage<ProcessBase>, process);
+    dispatch(gc->self(), &GarbageCollector::manage<ProcessBase>, process);
   }
 
   // We save the PID before enqueueing the process to avoid the race