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

Unified Diff: chrome/browser/renderer_host/browser_render_process_host.cc

Issue 21432: Fix a memory leak of the renderer thread objects in single process mode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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: chrome/browser/renderer_host/browser_render_process_host.cc
===================================================================
--- chrome/browser/renderer_host/browser_render_process_host.cc (revision 9876)
+++ chrome/browser/renderer_host/browser_render_process_host.cc (working copy)
@@ -13,11 +13,13 @@
#include "base/command_line.h"
#include "base/debug_util.h"
+#include "base/linked_ptr.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/shared_memory.h"
+#include "base/singleton.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/app/result_codes.h"
@@ -326,9 +328,12 @@
// communicating IO. This can lead to deadlocks where the RenderThread is
// waiting for the IO to complete, while the browsermain is trying to pass
// an event to the RenderThread.
- //
- // TODO: We should consider how to better cleanup threads on exit.
- base::Thread *render_thread = new RendererMainThread(channel_id);
+ RendererMainThread* render_thread = new RendererMainThread(channel_id);
+
+ // This singleton keeps track of our pointers to avoid a leak.
+ Singleton<std::vector<linked_ptr<RendererMainThread> > >::get()->push_back(
+ linked_ptr<RendererMainThread>(render_thread));
+
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
render_thread->StartWithOptions(options);
« 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