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

Side by Side Diff: chrome/renderer/render_thread.cc

Issue 350012: Purge memory for DBs in the renderer process. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | « no previous file | no next file » | 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/renderer/render_thread.h" 5 #include "chrome/renderer/render_thread.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #if defined(USE_SYSTEM_SQLITE)
12 #include <sqlite3.h>
13 #else
14 #include "third_party/sqlite/preprocessed/sqlite3.h"
15 #endif
16
11 #include "base/command_line.h" 17 #include "base/command_line.h"
12 #include "base/lazy_instance.h" 18 #include "base/lazy_instance.h"
13 #include "base/logging.h" 19 #include "base/logging.h"
14 #include "base/nullable_string16.h" 20 #include "base/nullable_string16.h"
15 #include "base/process_util.h" 21 #include "base/process_util.h"
16 #include "base/shared_memory.h" 22 #include "base/shared_memory.h"
17 #include "base/stats_table.h" 23 #include "base/stats_table.h"
18 #include "base/string_util.h" 24 #include "base/string_util.h"
19 #include "base/thread_local.h" 25 #include "base/thread_local.h"
20 #include "chrome/common/appcache/appcache_dispatcher.h" 26 #include "chrome/common/appcache/appcache_dispatcher.h"
(...skipping 19 matching lines...) Expand all
40 #include "chrome/renderer/external_extension.h" 46 #include "chrome/renderer/external_extension.h"
41 #include "chrome/renderer/loadtimes_extension_bindings.h" 47 #include "chrome/renderer/loadtimes_extension_bindings.h"
42 #include "chrome/renderer/net/render_dns_master.h" 48 #include "chrome/renderer/net/render_dns_master.h"
43 #include "chrome/renderer/render_process.h" 49 #include "chrome/renderer/render_process.h"
44 #include "chrome/renderer/render_view.h" 50 #include "chrome/renderer/render_view.h"
45 #include "chrome/renderer/renderer_webkitclient_impl.h" 51 #include "chrome/renderer/renderer_webkitclient_impl.h"
46 #include "chrome/renderer/renderer_web_database_observer.h" 52 #include "chrome/renderer/renderer_web_database_observer.h"
47 #include "chrome/renderer/socket_stream_dispatcher.h" 53 #include "chrome/renderer/socket_stream_dispatcher.h"
48 #include "chrome/renderer/user_script_slave.h" 54 #include "chrome/renderer/user_script_slave.h"
49 #include "ipc/ipc_message.h" 55 #include "ipc/ipc_message.h"
56 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h"
50 #include "webkit/api/public/WebCache.h" 57 #include "webkit/api/public/WebCache.h"
51 #include "webkit/api/public/WebColor.h" 58 #include "webkit/api/public/WebColor.h"
52 #include "webkit/api/public/WebCrossOriginPreflightResultCache.h" 59 #include "webkit/api/public/WebCrossOriginPreflightResultCache.h"
60 #include "webkit/api/public/WebDatabase.h"
61 #include "webkit/api/public/WebFontCache.h"
62 #include "webkit/api/public/WebKit.h"
53 #include "webkit/api/public/WebRuntimeFeatures.h" 63 #include "webkit/api/public/WebRuntimeFeatures.h"
54 #include "webkit/api/public/WebFontCache.h"
55 #include "webkit/api/public/WebColor.h"
56 #include "webkit/api/public/WebDatabase.h"
57 #include "webkit/api/public/WebKit.h"
58 #include "webkit/api/public/WebScriptController.h" 64 #include "webkit/api/public/WebScriptController.h"
59 #include "webkit/api/public/WebSecurityPolicy.h" 65 #include "webkit/api/public/WebSecurityPolicy.h"
60 #include "webkit/api/public/WebStorageEventDispatcher.h" 66 #include "webkit/api/public/WebStorageEventDispatcher.h"
61 #include "webkit/api/public/WebString.h" 67 #include "webkit/api/public/WebString.h"
62 #include "webkit/extensions/v8/benchmarking_extension.h" 68 #include "webkit/extensions/v8/benchmarking_extension.h"
63 #include "webkit/extensions/v8/gears_extension.h" 69 #include "webkit/extensions/v8/gears_extension.h"
64 #include "webkit/extensions/v8/interval_extension.h" 70 #include "webkit/extensions/v8/interval_extension.h"
65 #include "webkit/extensions/v8/playback_extension.h" 71 #include "webkit/extensions/v8/playback_extension.h"
66 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h"
67 72
68 #if defined(OS_WIN) 73 #if defined(OS_WIN)
69 #include <windows.h> 74 #include <windows.h>
70 #include <objbase.h> 75 #include <objbase.h>
71 #endif 76 #endif
72 77
73 using WebKit::WebCache; 78 using WebKit::WebCache;
74 using WebKit::WebCrossOriginPreflightResultCache; 79 using WebKit::WebCrossOriginPreflightResultCache;
80 using WebKit::WebFontCache;
75 using WebKit::WebRuntimeFeatures; 81 using WebKit::WebRuntimeFeatures;
76 using WebKit::WebFontCache;
77 using WebKit::WebSecurityPolicy; 82 using WebKit::WebSecurityPolicy;
78 using WebKit::WebScriptController; 83 using WebKit::WebScriptController;
79 using WebKit::WebString; 84 using WebKit::WebString;
80 using WebKit::WebStorageEventDispatcher; 85 using WebKit::WebStorageEventDispatcher;
81 using WebKit::WebView; 86 using WebKit::WebView;
82 87
83 namespace { 88 namespace {
84 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; 89 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
85 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; 90 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */;
86 91
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 // Clear the object cache (as much as possible; some live objects cannot be 575 // Clear the object cache (as much as possible; some live objects cannot be
571 // freed). 576 // freed).
572 WebCache::clear(); 577 WebCache::clear();
573 578
574 // Clear the font/glyph cache. 579 // Clear the font/glyph cache.
575 WebFontCache::clear(); 580 WebFontCache::clear();
576 581
577 // Clear the Cross-Origin Preflight cache. 582 // Clear the Cross-Origin Preflight cache.
578 WebCrossOriginPreflightResultCache::clear(); 583 WebCrossOriginPreflightResultCache::clear();
579 584
585 // Release all freeable memory from the SQLite process-global page cache (a
586 // low-level object which backs the Connection-specific page caches).
587 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0)
darin (slow to review) 2009/10/31 22:39:40 do we compile with -DSQLITE_ENABLE_MEMORY_MANAGEME
588 ;
589
580 // Repeatedly call the V8 idle notification until it returns true ("nothing 590 // Repeatedly call the V8 idle notification until it returns true ("nothing
581 // more to free"). Note that it makes more sense to do this than to implement 591 // more to free"). Note that it makes more sense to do this than to implement
582 // a new "delete everything" pass because object references make it difficult 592 // a new "delete everything" pass because object references make it difficult
583 // to free everything possible in just one pass. 593 // to free everything possible in just one pass.
584 while (!v8::V8::IdleNotification()) 594 while (!v8::V8::IdleNotification())
585 ; 595 ;
586 596
587 #if defined(OS_WIN) 597 #if defined(OS_WIN)
588 // Tell tcmalloc to release any free pages it's still holding. 598 // Tell tcmalloc to release any free pages it's still holding.
589 MallocExtension::instance()->ReleaseFreeMemory(); 599 MallocExtension::instance()->ReleaseFreeMemory();
590 #endif 600 #endif
591 } 601 }
592 602
593 void RenderThread::OnPurgePluginListCache(bool reload_pages) { 603 void RenderThread::OnPurgePluginListCache(bool reload_pages) {
594 EnsureWebKitInitialized(); 604 EnsureWebKitInitialized();
595 // The call below will cause a GetPlugins call with refresh=true, but at this 605 // The call below will cause a GetPlugins call with refresh=true, but at this
596 // point we already know that the browser has refreshed its list, so disable 606 // point we already know that the browser has refreshed its list, so disable
597 // refresh temporarily to prevent each renderer process causing the list to be 607 // refresh temporarily to prevent each renderer process causing the list to be
598 // regenerated. 608 // regenerated.
599 plugin_refresh_allowed_ = false; 609 plugin_refresh_allowed_ = false;
600 WebKit::resetPluginCache(reload_pages); 610 WebKit::resetPluginCache(reload_pages);
601 plugin_refresh_allowed_ = true; 611 plugin_refresh_allowed_ = true;
602 } 612 }
OLDNEW
« 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