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

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

Issue 10825250: Expose memory allocator internal stats and properties. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add jemalloc.h include Created 8 years, 3 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 | « base/allocator/allocator_shim.cc ('k') | 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) 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> 7 #include <stdlib.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 memset(&sandbox_info_, 0, sizeof(sandbox_info_)); 459 memset(&sandbox_info_, 0, sizeof(sandbox_info_));
460 #endif 460 #endif
461 } 461 }
462 462
463 ~ContentMainRunnerImpl() { 463 ~ContentMainRunnerImpl() {
464 if (is_initialized_ && !is_shutdown_) 464 if (is_initialized_ && !is_shutdown_)
465 Shutdown(); 465 Shutdown();
466 } 466 }
467 467
468 #if defined(USE_TCMALLOC) 468 #if defined(USE_TCMALLOC)
469 static bool GetPropertyThunk(const char* name, size_t* value) {
470 return MallocExtension::instance()->GetNumericProperty(name, value);
471 }
472
469 static void GetStatsThunk(char* buffer, int buffer_length) { 473 static void GetStatsThunk(char* buffer, int buffer_length) {
470 MallocExtension::instance()->GetStats(buffer, buffer_length); 474 MallocExtension::instance()->GetStats(buffer, buffer_length);
471 } 475 }
472 476
473 static void ReleaseFreeMemoryThunk() { 477 static void ReleaseFreeMemoryThunk() {
474 MallocExtension::instance()->ReleaseFreeMemory(); 478 MallocExtension::instance()->ReleaseFreeMemory();
475 } 479 }
476 #endif 480 #endif
477 481
478 482
(...skipping 18 matching lines...) Expand all
497 // process_util_linux.cc with the definition of 501 // process_util_linux.cc with the definition of
498 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a 502 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a
499 // dependency on TCMalloc. Really, we ought to have our allocator shim code 503 // dependency on TCMalloc. Really, we ought to have our allocator shim code
500 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. 504 // implement this EnableTerminationOnOutOfMemory() function. Whateverz.
501 // This works for now. 505 // This works for now.
502 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 506 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
503 // For tcmalloc, we need to tell it to behave like new. 507 // For tcmalloc, we need to tell it to behave like new.
504 tc_set_new_mode(1); 508 tc_set_new_mode(1);
505 509
506 // On windows, we've already set these thunks up in _heap_init() 510 // On windows, we've already set these thunks up in _heap_init()
511 base::allocator::SetGetPropertyFunction(GetPropertyThunk);
507 base::allocator::SetGetStatsFunction(GetStatsThunk); 512 base::allocator::SetGetStatsFunction(GetStatsThunk);
508 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); 513 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
509 514
510 // Provide optional hook for monitoring allocation quantities on a 515 // Provide optional hook for monitoring allocation quantities on a
511 // per-thread basis. Only set the hook if the environment indicates this 516 // per-thread basis. Only set the hook if the environment indicates this
512 // needs to be enabled. 517 // needs to be enabled.
513 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); 518 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime);
514 if (profiling && 519 if (profiling &&
515 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { 520 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) {
516 tracked_objects::SetAlternateTimeSource( 521 tracked_objects::SetAlternateTimeSource(
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 770
766 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 771 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
767 }; 772 };
768 773
769 // static 774 // static
770 ContentMainRunner* ContentMainRunner::Create() { 775 ContentMainRunner* ContentMainRunner::Create() {
771 return new ContentMainRunnerImpl(); 776 return new ContentMainRunnerImpl();
772 } 777 }
773 778
774 } // namespace content 779 } // namespace content
OLDNEW
« no previous file with comments | « base/allocator/allocator_shim.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698