From 69c019477ad0f4c68e8ba354a53b8932f9e0277a Mon Sep 17 00:00:00 2001 From: "earthdok@chromium.org" <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Tue, 15 Oct 2013 05:03:47 +0000 Subject: Invoke LeakSanitizer in BrowserProcessImpl::ReleaseModule(). Leak detection is normally invoked from an AtExit handler which runs very late in the shutdown process. This doesn't play well with Chrome, because memory is often intentionally leaked during shutdown, causing a flood of uninteresting leak reports. Instead we try to invoke leak detection at the earliest possible point in the shutdown process. BUG=307043 R=glider@chromium.org, thestig@chromium.org Review URL: https://codereview.chromium.org/26895007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228621 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_process_impl.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'chrome/browser/browser_process_impl.cc') diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index a48c7e2..6825a2e 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -12,6 +12,7 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/debug/alias.h" +#include "base/debug/leak_annotations.h" #include "base/path_service.h" #include "base/prefs/json_pref_store.h" #include "base/prefs/pref_registry_simple.h" @@ -341,6 +342,14 @@ unsigned int BrowserProcessImpl::ReleaseModule() { print_job_manager_->Shutdown(); #endif +#if defined(LEAK_SANITIZER) + // Check for memory leaks now, before we start shutting down threads. Doing + // this early means we won't report any shutdown-only leaks (as they have + // not yet happened at this point). + // If leaks are found, this will make the process exit immediately. + __lsan_do_leak_check(); +#endif + CHECK(base::MessageLoop::current()->is_running()); #if defined(OS_MACOSX) -- cgit v1.1