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

Side by Side Diff: base/process_util_linux.cc

Issue 399081: Enable TCMalloc on Linux by default. (Closed)
Patch Set: Oops, remove unintended change. 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
« no previous file with comments | « base/leak_annotations.h ('k') | base/process_util_unittest.cc » ('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) 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 "base/process_util.h" 5 #include "base/process_util.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <dirent.h> 8 #include <dirent.h>
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 507 }
508 508
509 void OnNoMemory() { 509 void OnNoMemory() {
510 OnNoMemorySize(0); 510 OnNoMemorySize(0);
511 } 511 }
512 512
513 } // namespace 513 } // namespace
514 514
515 extern "C" { 515 extern "C" {
516 516
517 #if defined(LINUX_USE_TCMALLOC) 517 #if !defined(LINUX_USE_TCMALLOC)
518
519 int tc_set_new_mode(int mode);
520
521 #else // defined(LINUX_USE_TCMALLOC)
522 518
523 typedef void* (*malloc_type)(size_t size); 519 typedef void* (*malloc_type)(size_t size);
524 typedef void* (*valloc_type)(size_t size); 520 typedef void* (*valloc_type)(size_t size);
525 typedef void* (*pvalloc_type)(size_t size); 521 typedef void* (*pvalloc_type)(size_t size);
526 522
527 typedef void* (*calloc_type)(size_t nmemb, size_t size); 523 typedef void* (*calloc_type)(size_t nmemb, size_t size);
528 typedef void* (*realloc_type)(void *ptr, size_t size); 524 typedef void* (*realloc_type)(void *ptr, size_t size);
529 typedef void* (*memalign_type)(size_t boundary, size_t size); 525 typedef void* (*memalign_type)(size_t boundary, size_t size);
530 526
531 typedef int (*posix_memalign_type)(void **memptr, size_t alignment, 527 typedef int (*posix_memalign_type)(void **memptr, size_t alignment,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 DIE_ON_OOM_1(malloc) 573 DIE_ON_OOM_1(malloc)
578 DIE_ON_OOM_1(valloc) 574 DIE_ON_OOM_1(valloc)
579 DIE_ON_OOM_1(pvalloc) 575 DIE_ON_OOM_1(pvalloc)
580 576
581 DIE_ON_OOM_2(calloc, size_t) 577 DIE_ON_OOM_2(calloc, size_t)
582 DIE_ON_OOM_2(realloc, void*) 578 DIE_ON_OOM_2(realloc, void*)
583 DIE_ON_OOM_2(memalign, size_t) 579 DIE_ON_OOM_2(memalign, size_t)
584 580
585 DIE_ON_OOM_3INT(posix_memalign) 581 DIE_ON_OOM_3INT(posix_memalign)
586 582
587 #endif // defined(LINUX_USE_TCMALLOC) 583 #endif // !defined(LINUX_USE_TCMALLOC)
588 584
589 } // extern C 585 } // extern C
590 586
591 void EnableTerminationOnOutOfMemory() { 587 void EnableTerminationOnOutOfMemory() {
592 // Set the new-out of memory handler. 588 // Set the new-out of memory handler.
593 std::set_new_handler(&OnNoMemory); 589 std::set_new_handler(&OnNoMemory);
594 // If we're using glibc's allocator, the above functions will override 590 // If we're using glibc's allocator, the above functions will override
595 // malloc and friends and make them die on out of memory. 591 // malloc and friends and make them die on out of memory.
596 #if defined(LINUX_USE_TCMALLOC)
597 // For tcmalloc, we just need to tell it to behave like new.
598 tc_set_new_mode(1);
599 #endif
600 } 592 }
601 593
602 } // namespace base 594 } // namespace base
OLDNEW
« no previous file with comments | « base/leak_annotations.h ('k') | base/process_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698