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

Side by Side Diff: content/app/content_main_runner.cc

Issue 10820063: Enable memory profiler when TC_MALLOC is enabled for (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | « no previous file | third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stdlib.h>
8
7 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
8 #include "base/at_exit.h" 10 #include "base/at_exit.h"
9 #include "base/command_line.h" 11 #include "base/command_line.h"
10 #include "base/debug/debugger.h" 12 #include "base/debug/debugger.h"
11 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
12 #include "base/file_path.h" 14 #include "base/file_path.h"
13 #include "base/i18n/icu_util.h" 15 #include "base/i18n/icu_util.h"
14 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
15 #include "base/logging.h" 17 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/metrics/stats_table.h" 19 #include "base/metrics/stats_table.h"
18 #include "base/path_service.h" 20 #include "base/path_service.h"
19 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/profiler/alternate_timer.h"
20 #include "base/stringprintf.h" 23 #include "base/stringprintf.h"
21 #include "base/string_number_conversions.h" 24 #include "base/string_number_conversions.h"
22 #include "content/browser/browser_main.h" 25 #include "content/browser/browser_main.h"
23 #include "content/common/set_process_title.h" 26 #include "content/common/set_process_title.h"
24 #include "content/common/url_schemes.h" 27 #include "content/common/url_schemes.h"
25 #include "content/public/app/content_main_delegate.h" 28 #include "content/public/app/content_main_delegate.h"
26 #include "content/public/app/startup_helper_win.h" 29 #include "content/public/app/startup_helper_win.h"
27 #include "content/public/browser/content_browser_client.h" 30 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/common/content_client.h" 31 #include "content/public/common/content_client.h"
29 #include "content/public/common/content_constants.h" 32 #include "content/public/common/content_constants.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // dependency on TCMalloc. Really, we ought to have our allocator shim code 446 // dependency on TCMalloc. Really, we ought to have our allocator shim code
444 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. 447 // implement this EnableTerminationOnOutOfMemory() function. Whateverz.
445 // This works for now. 448 // This works for now.
446 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 449 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
447 // For tcmalloc, we need to tell it to behave like new. 450 // For tcmalloc, we need to tell it to behave like new.
448 tc_set_new_mode(1); 451 tc_set_new_mode(1);
449 452
450 // On windows, we've already set these thunks up in _heap_init() 453 // On windows, we've already set these thunks up in _heap_init()
451 base::allocator::SetGetStatsFunction(GetStatsThunk); 454 base::allocator::SetGetStatsFunction(GetStatsThunk);
452 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); 455 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
456
457 // Provide optional hook for monitoring allocation quantities on a
458 // per-thread basis. Only set the hook if the environment indicates this
459 // needs to be enabled.
460 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime);
461 if (profiling &&
462 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) {
463 tracked_objects::SetAlternateTimeSource(
464 MallocExtension::GetBytesAllocatedOnCurrentThread,
465 tracked_objects::TIME_SOURCE_TYPE_TCMALLOC);
466 }
453 #endif 467 #endif
454 468
455 // On Android, 469 // On Android,
456 // - setlocale() is not supported. 470 // - setlocale() is not supported.
457 // - We do not override the signal handlers so that we can get 471 // - We do not override the signal handlers so that we can get
458 // stack trace when crashing. 472 // stack trace when crashing.
459 // - The ipc_fd is passed through the Java service. 473 // - The ipc_fd is passed through the Java service.
460 // Thus, these are all disabled. 474 // Thus, these are all disabled.
461 #if !defined(OS_ANDROID) 475 #if !defined(OS_ANDROID)
462 // Set C library locale to make sure CommandLine can parse argument values 476 // Set C library locale to make sure CommandLine can parse argument values
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 703
690 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 704 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
691 }; 705 };
692 706
693 // static 707 // static
694 ContentMainRunner* ContentMainRunner::Create() { 708 ContentMainRunner* ContentMainRunner::Create() {
695 return new ContentMainRunnerImpl(); 709 return new ContentMainRunnerImpl();
696 } 710 }
697 711
698 } // namespace content 712 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698