diff options
author | erikghill@gmail.com <erikghill@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-26 21:06:35 +0000 |
---|---|---|
committer | erikghill@gmail.com <erikghill@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-26 21:06:35 +0000 |
commit | d448c32f07686a7060a21943a3634bd156d4ed69 (patch) | |
tree | eb919680f210c9cf6d7a0aaefbdbd8aeb3026188 | |
parent | 47ef6148e87b5410135e35afe4259344a2a458e4 (diff) | |
download | chromium_src-d448c32f07686a7060a21943a3634bd156d4ed69.zip chromium_src-d448c32f07686a7060a21943a3634bd156d4ed69.tar.gz chromium_src-d448c32f07686a7060a21943a3634bd156d4ed69.tar.bz2 |
Eliminated memory growth issue by removing null objects from a list that was accumulating them. Now, the objects are removed from the list when they are no longer needed, instead of being set to null.BUG=110459TEST=1. Go to any webpage 2. Go to a different webpage 3. Go back to step 1 and repeat many times. Before the fix pool_objects_ in win2k_threadpool grows with each new webpage visited. After the fix pool_objects_.size() is bounded even as new webpages are visited.
Review URL: http://codereview.chromium.org/9243014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119287 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | sandbox/src/win2k_threadpool.cc | 32 | ||||
-rw-r--r-- | sandbox/src/win2k_threadpool.h | 8 |
3 files changed, 19 insertions, 22 deletions
@@ -159,3 +159,4 @@ Lu Guanqun <guanqun.lu@gmail.com> François Beaufort <beaufort.francois@gmail.com> Eriq Augustine <eriq.augustine@gmail.com> Francois Kritzinger <francoisk777@gmail.com> +Erik Hill <erikghill@gmail.com> diff --git a/sandbox/src/win2k_threadpool.cc b/sandbox/src/win2k_threadpool.cc index 2e2ffe6..fe2473e 100644 --- a/sandbox/src/win2k_threadpool.cc +++ b/sandbox/src/win2k_threadpool.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,10 +8,10 @@ namespace sandbox { -bool Win2kThreadPool::RegisterWait(const void* client, HANDLE waitable_object, +bool Win2kThreadPool::RegisterWait(const void* cookie, HANDLE waitable_object, CrossCallIPCCallback callback, void* context) { - if (0 == client) { + if (0 == cookie) { return false; } HANDLE pool_object = NULL; @@ -20,7 +20,7 @@ bool Win2kThreadPool::RegisterWait(const void* client, HANDLE waitable_object, context, INFINITE, WT_EXECUTEDEFAULT)) { return false; } - PoolObject pool_obj = {client, pool_object}; + PoolObject pool_obj = {cookie, pool_object}; AutoLock lock(&lock_); pool_objects_.push_back(pool_obj); return true; @@ -31,27 +31,23 @@ bool Win2kThreadPool::UnRegisterWaits(void* cookie) { return false; } AutoLock lock(&lock_); - PoolObjects::iterator it; - for (it = pool_objects_.begin(); it != pool_objects_.end(); ++it) { + bool success = true; + PoolObjects::iterator it = pool_objects_.begin(); + while (it != pool_objects_.end()) { if (it->cookie == cookie) { - if (!::UnregisterWaitEx(it->wait, INVALID_HANDLE_VALUE)) - return false; - it->cookie = 0; + HANDLE wait = it->wait; + it = pool_objects_.erase(it); + success &= (::UnregisterWaitEx(wait, INVALID_HANDLE_VALUE) != 0); + } else { + ++it; } } - return true; + return success; } size_t Win2kThreadPool::OutstandingWaits() { - size_t count =0; AutoLock lock(&lock_); - PoolObjects::iterator it; - for (it = pool_objects_.begin(); it != pool_objects_.end(); ++it) { - if (it->cookie != 0) { - ++count; - } - } - return count; + return pool_objects_.size(); } Win2kThreadPool::~Win2kThreadPool() { diff --git a/sandbox/src/win2k_threadpool.h b/sandbox/src/win2k_threadpool.h index 79152a6..8593fa3 100644 --- a/sandbox/src/win2k_threadpool.h +++ b/sandbox/src/win2k_threadpool.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,20 +22,20 @@ namespace sandbox { // arises. // // This implementation simply thunks to the nice thread pool API of win2k. -class Win2kThreadPool : public ThreadProvider { +class Win2kThreadPool : public ThreadProvider { public: Win2kThreadPool() { ::InitializeCriticalSection(&lock_); } virtual ~Win2kThreadPool(); - virtual bool RegisterWait(const void* client, HANDLE waitable_object, + virtual bool RegisterWait(const void* cookie, HANDLE waitable_object, CrossCallIPCCallback callback, void* context); virtual bool UnRegisterWaits(void* cookie); - // Returns the total number of non-released wait objects associated with + // Returns the total number of wait objects associated with // the thread pool. size_t OutstandingWaits(); |