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

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: 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 | no next file » | 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..72bd105f9a2827a892357718a28710dfb6a30e6a 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -45,8 +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)
+ // Hold a (cyclic) ref to |worker_pool|, since we want to keep it
+ // around as long as we are running. Note that this (deliberately)
brettw 2012/02/28 04:38:46 Is the leaks on shutdown comment still valid? If s
akalin 2012/02/28 22:10:33 Done.
// leaks on shutdown.
Worker(const scoped_refptr<SequencedWorkerPool>& worker_pool,
int thread_number,
@@ -57,7 +57,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 +226,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 | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698