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

Side by Side Diff: chrome/browser/memory_purger.cc

Issue 660118: Merge the LINUX_TC_MALLOC #define with the existing TC_MALLOC #define.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/chrome_exe_main_gtk.cc ('k') | chrome/renderer/render_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/memory_purger.h" 5 #include "chrome/browser/memory_purger.h"
6 6
7 #include <set>
8
7 #include "base/thread.h" 9 #include "base/thread.h"
8 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
9 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/history/history.h" 12 #include "chrome/browser/history/history.h"
11 #include "chrome/browser/in_process_webkit/webkit_context.h" 13 #include "chrome/browser/in_process_webkit/webkit_context.h"
12 #include "chrome/browser/net/url_request_context_getter.h" 14 #include "chrome/browser/net/url_request_context_getter.h"
13 #include "chrome/browser/profile_manager.h" 15 #include "chrome/browser/profile_manager.h"
14 #include "chrome/browser/renderer_host/backing_store_manager.h" 16 #include "chrome/browser/renderer_host/backing_store_manager.h"
15 #include "chrome/browser/renderer_host/render_process_host.h" 17 #include "chrome/browser/renderer_host/render_process_host.h"
16 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 18 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 130 }
129 131
130 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, 132 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE,
131 NewRunnableMethod(purge_memory_io_helper.get(), 133 NewRunnableMethod(purge_memory_io_helper.get(),
132 &PurgeMemoryIOHelper::PurgeMemoryOnIOThread)); 134 &PurgeMemoryIOHelper::PurgeMemoryOnIOThread));
133 135
134 // TODO(pkasting): 136 // TODO(pkasting):
135 // * Purge AppCache memory. Not yet implemented sufficiently. 137 // * Purge AppCache memory. Not yet implemented sufficiently.
136 // * Browser-side DatabaseTracker. Not implemented sufficiently. 138 // * Browser-side DatabaseTracker. Not implemented sufficiently.
137 139
138 #if defined(OS_WIN) && defined(USE_TCMALLOC) 140 #if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC)
139 // Tell tcmalloc to release any free pages it's still holding. 141 // Tell tcmalloc to release any free pages it's still holding.
140 // 142 //
141 // TODO(pkasting): A lot of the above calls kick off actions on other threads. 143 // TODO(pkasting): A lot of the above calls kick off actions on other threads.
142 // Maybe we should find a way to avoid calling this until those actions 144 // Maybe we should find a way to avoid calling this until those actions
143 // complete? 145 // complete?
144 MallocExtension::instance()->ReleaseFreeMemory(); 146 MallocExtension::instance()->ReleaseFreeMemory();
145 #endif 147 #endif
146 } 148 }
147 149
148 // static 150 // static
149 void MemoryPurger::PurgeRenderers() { 151 void MemoryPurger::PurgeRenderers() {
150 // Direct all renderers to free everything they can. 152 // Direct all renderers to free everything they can.
151 // 153 //
152 // Concern: Telling a bunch of renderer processes to destroy their data may 154 // Concern: Telling a bunch of renderer processes to destroy their data may
153 // cause them to page everything in to do it, which could take a lot of time/ 155 // cause them to page everything in to do it, which could take a lot of time/
154 // cause jank. 156 // cause jank.
155 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); 157 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
156 !i.IsAtEnd(); i.Advance()) 158 !i.IsAtEnd(); i.Advance())
157 PurgeRendererForHost(i.GetCurrentValue()); 159 PurgeRendererForHost(i.GetCurrentValue());
158 } 160 }
159 161
160 // static 162 // static
161 void MemoryPurger::PurgeRendererForHost(RenderProcessHost* host) { 163 void MemoryPurger::PurgeRendererForHost(RenderProcessHost* host) {
162 // Direct the renderer to free everything it can. 164 // Direct the renderer to free everything it can.
163 host->Send(new ViewMsg_PurgeMemory()); 165 host->Send(new ViewMsg_PurgeMemory());
164 } 166 }
OLDNEW
« no previous file with comments | « chrome/app/chrome_exe_main_gtk.cc ('k') | chrome/renderer/render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698