Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: base/threading/sequenced_worker_pool.cc

Issue 9480016: Fix memory leak in SequencedWorkerPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, add suppression removal Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/valgrind/drmemory/suppressions_full.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/sequenced_worker_pool.cc
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 7679c1532eabf440285006ab951d9c5df4f66198..bbcf2482adb209e12dffbf570e9545d280b5b8ef 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -45,9 +45,8 @@ struct SequencedTask {
class SequencedWorkerPool::Worker : public SimpleThread {
public:
- // Hold a ref to |worker_pool|, since we want to keep it around even
- // if it doesn't join our thread. Note that this (deliberately)
- // leaks on shutdown.
+ // Hold a (cyclic) ref to |worker_pool|, since we want to keep it
+ // around as long as we are running.
Worker(const scoped_refptr<SequencedWorkerPool>& worker_pool,
int thread_number,
const std::string& thread_name_prefix);
@@ -57,7 +56,7 @@ class SequencedWorkerPool::Worker : public SimpleThread {
virtual void Run() OVERRIDE;
private:
- const scoped_refptr<SequencedWorkerPool> worker_pool_;
+ scoped_refptr<SequencedWorkerPool> worker_pool_;
DISALLOW_COPY_AND_ASSIGN(Worker);
};
@@ -226,6 +225,8 @@ void SequencedWorkerPool::Worker::Run() {
// having these worker objects at all, but that method lacks the ability to
// send thread-specific information easily to the thread loop.
worker_pool_->inner_->ThreadLoop(this);
+ // Release our cyclic reference once we're done.
+ worker_pool_ = NULL;
}
// Inner definitions ---------------------------------------------------------
« no previous file with comments | « no previous file | tools/valgrind/drmemory/suppressions_full.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698