diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-17 23:01:12 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-17 23:01:12 +0000 |
commit | 43f2be0f6498026903681a3bdf27e90282b5cc52 (patch) | |
tree | 63c7a751deff6aafa5be4e5843dfbe16fe0dc102 /chrome | |
parent | 04db40ce93518e01dd5c02908ea7ef9c7ce9df50 (diff) | |
download | chromium_src-43f2be0f6498026903681a3bdf27e90282b5cc52.zip chromium_src-43f2be0f6498026903681a3bdf27e90282b5cc52.tar.gz chromium_src-43f2be0f6498026903681a3bdf27e90282b5cc52.tar.bz2 |
Fix a memory leak of the renderer thread objects in single process mode.
BUG=6538
Review URL: http://codereview.chromium.org/21432
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index f587f05..20bd867 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -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 @@ bool BrowserRenderProcessHost::Init() { // 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); |