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
[email protected], [email protected]
Review URL: https://codereview.chromium.org/26895007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228621 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index a48c7e2..6825a2e2 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 @@
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)