#include "config.h"
#include <new>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include "packed-cache-inl.h"
#include "base/commandlineflags.h"
#include "base/basictypes.h"
#include "base/sysinfo.h"
#include "base/spinlock.h"
#include <google/malloc_hook.h>
#include <google/malloc_extension.h>
#include "internal_logging.h"
#include "pagemap.h"
#include "system-alloc.h"
#include "maybe_threads.h"
#include <google/stacktrace.h>
構成 | |
struct | TCEntry |
class | PageHeapAllocator< T > |
struct | Span |
struct | StackTrace |
class | MapSelector< BITS > |
class | MapSelector< 32 > |
class | TCMalloc_PageHeap |
struct | TCMalloc_PageHeap::SpanList |
class | TCMalloc_ThreadCache_FreeList |
class | TCMalloc_ThreadCache |
class | TCMalloc_Central_FreeList |
class | TCMalloc_Central_FreeListPadded |
struct | TCMallocStats |
class | TCMallocImplementation |
class | TCMallocGuard |
マクロ定義 | |
#define | __THROW |
#define | Event(s, o, v) ((void) 0) |
#define | pageheap ((TCMalloc_PageHeap*) pageheap_memory) |
型定義 | |
typedef uintptr_t | PageID |
typedef uintptr_t | Length |
関数 | |
DEFINE_int64 (tcmalloc_sample_parameter, 262147,"Twice the approximate gap between sampling actions."" Must be a prime number. Otherwise will be rounded up to a "" larger prime number") | |
DEFINE_double (tcmalloc_release_rate, 10,"Rate at which we release unused memory to the system. ""Zero means we never release memory back to the system. ""Increase this flag to return memory faster; decrease it ""to return memory slower. Reasonable rates are in the ""range [0,10]") | |
static int | ClassIndex (size_t s) |
static int | LgFloor (size_t n) |
static void * | SLL_Next (void *t) |
static void | SLL_SetNext (void *t, void *n) |
static void | SLL_Push (void **list, void *element) |
static void * | SLL_Pop (void **list) |
static void | SLL_PopRange (void **head, int N, void **start, void **end) |
static void | SLL_PushRange (void **head, void *start, void *end) |
static size_t | SLL_Size (void *head) |
static int | SizeClass (size_t size) |
static size_t | ByteSizeForClass (size_t cl) |
static int | NumMoveSize (size_t size) |
static void | InitSizeClasses () |
static void * | MetaDataAlloc (size_t bytes) |
static Length | pages (size_t bytes) |
static size_t | AllocationSize (size_t bytes) |
static Span * | NewSpan (PageID p, Length len) |
static void | DeleteSpan (Span *span) |
static void | DLL_Init (Span *list) |
static void | DLL_Remove (Span *span) |
static bool | DLL_IsEmpty (const Span *list) |
static int | DLL_Length (const Span *list) |
static void | DLL_Prepend (Span *list, Span *span) |
static double | PagesToMB (uint64_t pages) |
static void | RecordGrowth (size_t growth) |
static void | ReleaseFreeList (Span *list, Span *returned) |
static void | ExtractStats (TCMallocStats *r, uint64_t *class_count) |
static void | DumpStats (TCMalloc_Printer *out, int level) |
static void | PrintStats (int level) |
static void ** | DumpStackTraces () |
static void ** | DumpHeapGrowthStackTraces () |
static Span * | DoSampledAllocation (size_t size) |
static bool | CheckCachedSizeClass (void *ptr) |
static void * | CheckedMallocResult (void *result) |
static void * | SpanToMallocResult (Span *span) |
static void * | do_malloc (size_t size) |
static void | do_free (void *ptr) |
static void * | do_memalign (size_t align, size_t size) |
static void | do_malloc_stats () |
static int | do_mallopt (int cmd, int value) |
void * | malloc (size_t size) __THROW ATTRIBUTE_SECTION(google_malloc) |
void | free (void *ptr) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | realloc (void *ptr, size_t size) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | calloc (size_t nmemb, size_t size) __THROW ATTRIBUTE_SECTION(google_malloc) |
void | cfree (void *ptr) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | memalign (size_t __alignment, size_t __size) __THROW ATTRIBUTE_SECTION(google_malloc) |
int | posix_memalign (void **ptr, size_t align, size_t size) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | valloc (size_t __size) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | pvalloc (size_t __size) __THROW ATTRIBUTE_SECTION(google_malloc) |
static void * | MemalignOverride (size_t align, size_t size, const void *caller) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | operator new (size_t size) ATTRIBUTE_SECTION(google_malloc) |
void | operator delete (void *p) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | operator new[] (size_t size) ATTRIBUTE_SECTION(google_malloc) |
void | operator delete[] (void *p) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | operator new (size_t size, const std::nothrow_t &) __THROW ATTRIBUTE_SECTION(google_malloc) |
void | operator delete (void *p, const std::nothrow_t &) __THROW ATTRIBUTE_SECTION(google_malloc) |
void * | operator new[] (size_t size, const std::nothrow_t &) __THROW ATTRIBUTE_SECTION(google_malloc) |
void | operator delete[] (void *p, const std::nothrow_t &) __THROW ATTRIBUTE_SECTION(google_malloc) |
static void * | cpp_alloc (size_t size, bool nothrow) |
void | malloc_stats (void) |
int | mallopt (int cmd, int value) |
変数 | |
static const size_t | kPageShift = 12 |
static const size_t | kPageSize = 1 << kPageShift |
static const size_t | kMaxSize = 8u * kPageSize |
static const size_t | kAlignShift = 3 |
static const size_t | kAlignment = 1 << kAlignShift |
static const size_t | kNumClasses = 68 |
static const size_t | kPageMapBigAllocationThreshold = 128 << 20 |
static const int | kMinSystemAlloc = 1 << (20 - kPageShift) |
static int | num_objects_to_move [kNumClasses] |
static const int | kMaxFreeListLength = 256 |
static const size_t | kMinThreadCacheSize = kMaxSize * 2 |
static const size_t | kMaxThreadCacheSize = 2 << 20 |
static const size_t | kDefaultOverallThreadCacheSize = 16 << 20 |
static const size_t | kMaxPages = kMinSystemAlloc |
static unsigned int | primes_list [] |
static size_t | sample_period = 262147 |
static SpinLock | sample_period_lock (SpinLock::LINKER_INITIALIZED) |
static const int | kMaxSmallSize = 1024 |
static const int | shift_amount [2] = { 3, 7 } |
static const int | add_amount [2] = { 7, 127 + (120 << 7) } |
static unsigned char | class_array [377] |
static size_t | class_to_size [kNumClasses] |
static size_t | class_to_pages [kNumClasses] |
static const int | kNumTransferEntries = kNumClasses |
static uint64_t | metadata_system_bytes = 0 |
static const Length | kMaxValidPages = (~static_cast<Length>(0)) >> kPageShift |
static PageHeapAllocator< Span > | span_allocator |
static const int | kMaxStackDepth = 31 |
static PageHeapAllocator < StackTrace > | stacktrace_allocator |
static Span | sampled_objects |
static StackTrace * | growth_stacks = NULL |
static TCMalloc_Central_FreeListPadded | central_cache [kNumClasses] |
static SpinLock | pageheap_lock (SpinLock::LINKER_INITIALIZED) |
static char | pageheap_memory [sizeof(TCMalloc_PageHeap)] |
static bool | phinited = false |
static bool | tsd_inited = false |
static pthread_key_t | heap_key |
static PageHeapAllocator < TCMalloc_ThreadCache > | threadheap_allocator |
static TCMalloc_ThreadCache * | thread_heaps = NULL |
static int | thread_heap_count = 0 |
static size_t | overall_thread_cache_size = kDefaultOverallThreadCacheSize |
static volatile size_t | per_thread_cache_size = kMaxThreadCacheSize |
static TCMallocGuard | module_enter_exit_hook |
static SpinLock | set_new_handler_lock (SpinLock::LINKER_INITIALIZED) |
static size_t | pagesize = 0 |
void *(* | __memalign_hook )(size_t, size_t, const void *) = MemalignOverride |
#define __THROW |
tcmalloc-0.93/tcmalloc.cc の 161 行で定義されています。
#define Event | ( | s, | |||
o, | |||||
v | ) | ((void) 0) |
tcmalloc-0.93/tcmalloc.cc の 678 行で定義されています。
#define pageheap ((TCMalloc_PageHeap*) pageheap_memory) |
tcmalloc-0.93/tcmalloc.cc の 1594 行で定義されています。
typedef uintptr_t Length |
tcmalloc-0.93/tcmalloc.cc の 625 行で定義されています。
typedef uintptr_t PageID |
tcmalloc-0.93/tcmalloc.cc の 622 行で定義されています。
static size_t AllocationSize | ( | size_t | bytes | ) | [static] |
static size_t ByteSizeForClass | ( | size_t | cl | ) | [inline, static] |
tcmalloc-0.93/tcmalloc.cc の 389 行で定義されています。
void* calloc | ( | size_t | nmemb, | |
size_t | size | |||
) |
tcmalloc-0.8/tcmalloc.cc の 2350 行で定義されています。
参照先 do_malloc(), と MallocHook::InvokeNewHook().
参照元 __libc_calloc().
void cfree | ( | void * | ptr | ) |
tcmalloc-0.8/tcmalloc.cc の 2363 行で定義されています。
static bool CheckCachedSizeClass | ( | void * | ptr | ) | [inline, static] |
static void* CheckedMallocResult | ( | void * | result | ) | [inline, static] |
tcmalloc-0.93/tcmalloc.cc の 2630 行で定義されています。
参照先 ASSERT, と CheckCachedSizeClass().
参照元 do_malloc(), do_memalign(), と SpanToMallocResult().
static int ClassIndex | ( | size_t | s | ) | [inline, static] |
static void* cpp_alloc | ( | size_t | size, | |
bool | nothrow | |||
) | [inline, static] |
DEFINE_double | ( | tcmalloc_release_rate | , | |
10 | , | |||
"Rate at which we release unused memory to the system. ""Zero means we never release memory back to the system. ""Increase this flag to return memory faster; decrease it ""to return memory slower. Reasonable rates are in the ""range " | [0, 10] | |||
) |
DEFINE_int64 | ( | tcmalloc_sample_parameter | , | |
262147 | , | |||
"Twice the approximate gap between sampling actions."" Must be a prime number. Otherwise will be rounded up to a "" larger prime number" | ||||
) |
static void DeleteSpan | ( | Span * | span | ) | [static] |
static void DLL_Init | ( | Span * | list | ) | [static] |
static bool DLL_IsEmpty | ( | const Span * | list | ) | [inline, static] |
static int DLL_Length | ( | const Span * | list | ) | [static] |
static void DLL_Remove | ( | Span * | span | ) | [static] |
static void do_free | ( | void * | ptr | ) | [inline, static] |
static void* do_malloc | ( | size_t | size | ) | [inline, static] |
static void do_malloc_stats | ( | ) | [inline, static] |
static int do_mallopt | ( | int | cmd, | |
int | value | |||
) | [inline, static] |
static void* do_memalign | ( | size_t | align, | |
size_t | size | |||
) | [static] |
static Span* DoSampledAllocation | ( | size_t | size | ) | [static] |
static void** DumpHeapGrowthStackTraces | ( | ) | [static] |
static void** DumpStackTraces | ( | ) | [static] |
tcmalloc-0.93/tcmalloc.cc の 2367 行で定義されています。
参照先 ASSERT, StackTrace::depth, MESSAGE, Span::next, pageheap_lock, StackTrace::size, と StackTrace::stack.
static void DumpStats | ( | TCMalloc_Printer * | out, | |
int | level | |||
) | [static] |
tcmalloc-0.93/tcmalloc.cc の 2305 行で定義されています。
参照先 ByteSizeForClass(), TCMallocStats::central_bytes, ExtractStats(), PageHeapAllocator< T >::inuse(), TCMallocStats::metadata_bytes, pageheap, TCMallocStats::pageheap_bytes, pageheap_lock, TCMalloc_Printer::printf(), PRIu64, PRIuS, TCMallocStats::system_bytes, TCMallocStats::thread_bytes, と TCMallocStats::transfer_bytes.
static void ExtractStats | ( | TCMallocStats * | r, | |
uint64_t * | class_count | |||
) | [static] |
tcmalloc-0.93/tcmalloc.cc の 2270 行で定義されています。
参照先 ByteSizeForClass(), TCMallocStats::central_bytes, TCMalloc_Central_FreeList::length(), length, TCMallocStats::metadata_bytes, pageheap, TCMallocStats::pageheap_bytes, pageheap_lock, TCMallocStats::system_bytes, TCMalloc_Central_FreeList::tc_length(), TCMallocStats::thread_bytes, と TCMallocStats::transfer_bytes.
void free | ( | void * | ptr | ) |
static void InitSizeClasses | ( | ) | [static] |
tcmalloc-0.93/tcmalloc.cc の 418 行で定義されています。
参照先 ByteSizeForClass(), ClassIndex(), LgFloor(), MESSAGE, NumMoveSize(), PRIuS, と SizeClass().
static int LgFloor | ( | size_t | n | ) | [inline, static] |
void* malloc | ( | size_t | size | ) |
void malloc_stats | ( | void | ) |
int mallopt | ( | int | cmd, | |
int | value | |||
) |
void* memalign | ( | size_t | __alignment, | |
size_t | __size | |||
) |
tcmalloc-0.8/tcmalloc.cc の 2495 行で定義されています。
static void * MemalignOverride | ( | size_t | align, | |
size_t | size, | |||
const void * | caller | |||
) | [static] |
static void* MetaDataAlloc | ( | size_t | bytes | ) | [static] |
tcmalloc-0.93/tcmalloc.cc の 683 行で定義されています。
参照先 Span::length, PageHeapAllocator< T >::New(), と Span::start.
static int NumMoveSize | ( | size_t | size | ) | [static] |
tcmalloc-0.93/tcmalloc.cc の 394 行で定義されています。
void operator delete | ( | void * | p, | |
const std::nothrow_t & | ||||
) |
void operator delete | ( | void * | p | ) |
void operator delete[] | ( | void * | p, | |
const std::nothrow_t & | ||||
) |
void operator delete[] | ( | void * | p | ) |
void* operator new | ( | size_t | size, | |
const std::nothrow_t & | ||||
) |
void* operator new | ( | size_t | size | ) |
void* operator new[] | ( | size_t | size, | |
const std::nothrow_t & | ||||
) |
void* operator new[] | ( | size_t | size | ) |
static Length pages | ( | size_t | bytes | ) | [inline, static] |
tcmalloc-0.93/tcmalloc.cc の 631 行で定義されています。
static double PagesToMB | ( | uint64_t | pages | ) | [static] |
tcmalloc-0.93/tcmalloc.cc の 1186 行で定義されています。
int posix_memalign | ( | void ** | ptr, | |
size_t | align, | |||
size_t | size | |||
) |
tcmalloc-0.8/tcmalloc.cc の 2501 行で定義されています。
static void PrintStats | ( | int | level | ) | [static] |
void* pvalloc | ( | size_t | __size | ) |
tcmalloc-0.8/tcmalloc.cc の 2528 行で定義されています。
void* realloc | ( | void * | ptr, | |
size_t | size | |||
) |
static void RecordGrowth | ( | size_t | growth | ) | [static] |
tcmalloc-0.93/tcmalloc.cc の 1251 行で定義されています。
参照先 StackTrace::depth, GetStackTrace(), PageHeapAllocator< T >::New(), StackTrace::size, と StackTrace::stack.
tcmalloc-0.93/tcmalloc.cc の 1333 行で定義されています。
参照先 DLL_IsEmpty(), DLL_Prepend(), DLL_Remove(), Span::length, Span::prev, Span::start, と TCMalloc_SystemRelease().
static int SizeClass | ( | size_t | size | ) | [inline, static] |
static void* SLL_Next | ( | void * | t | ) | [inline, static] |
tcmalloc-0.93/tcmalloc.cc の 324 行で定義されています。
static void* SLL_Pop | ( | void ** | list | ) | [inline, static] |
static void SLL_PopRange | ( | void ** | head, | |
int | N, | |||
void ** | start, | |||
void ** | end | |||
) | [inline, static] |
static void SLL_Push | ( | void ** | list, | |
void * | element | |||
) | [inline, static] |
static void SLL_PushRange | ( | void ** | head, | |
void * | start, | |||
void * | end | |||
) | [inline, static] |
static void SLL_SetNext | ( | void * | t, | |
void * | n | |||
) | [inline, static] |
tcmalloc-0.93/tcmalloc.cc の 328 行で定義されています。
static size_t SLL_Size | ( | void * | head | ) | [inline, static] |
static void* SpanToMallocResult | ( | Span * | span | ) | [inline, static] |
tcmalloc-0.93/tcmalloc.cc の 2636 行で定義されています。
参照先 CheckedMallocResult(), pageheap, と Span::start.
参照元 do_malloc(), と do_memalign().
void* valloc | ( | size_t | __size | ) |
tcmalloc-0.8/tcmalloc.cc の 2520 行で定義されています。
void*(* __memalign_hook)(size_t, size_t, const void *) = MemalignOverride |
const int add_amount[2] = { 7, 127 + (120 << 7) } [static] |
tcmalloc-0.93/tcmalloc.cc の 276 行で定義されています。
tcmalloc-0.93/tcmalloc.cc の 1585 行で定義されています。
unsigned char class_array[377] [static] |
tcmalloc-0.93/tcmalloc.cc の 277 行で定義されています。
size_t class_to_pages[kNumClasses] [static] |
tcmalloc-0.93/tcmalloc.cc の 289 行で定義されています。
size_t class_to_size[kNumClasses] [static] |
tcmalloc-0.93/tcmalloc.cc の 286 行で定義されています。
StackTrace* growth_stacks = NULL [static] |
tcmalloc-0.93/tcmalloc.cc の 769 行で定義されています。
pthread_key_t heap_key [static] |
tcmalloc-0.93/tcmalloc.cc の 1612 行で定義されています。
tcmalloc-0.93/tcmalloc.cc の 1733 行で定義されています。
const size_t kAlignment = 1 << kAlignShift [static] |
tcmalloc-0.93/tcmalloc.cc の 175 行で定義されています。
const size_t kAlignShift = 3 [static] |
tcmalloc-0.93/tcmalloc.cc の 174 行で定義されています。
const size_t kDefaultOverallThreadCacheSize = 16 << 20 [static] |
tcmalloc-0.93/tcmalloc.cc の 209 行で定義されています。
const int kMaxFreeListLength = 256 [static] |
tcmalloc-0.93/tcmalloc.cc の 202 行で定義されています。
const size_t kMaxPages = kMinSystemAlloc [static] |
tcmalloc-0.93/tcmalloc.cc の 213 行で定義されています。
const size_t kMaxSize = 8u * kPageSize [static] |
tcmalloc-0.93/tcmalloc.cc の 173 行で定義されています。
const int kMaxSmallSize = 1024 [static] |
tcmalloc-0.93/tcmalloc.cc の 274 行で定義されています。
const int kMaxStackDepth = 31 [static] |
tcmalloc-0.93/tcmalloc.cc の 756 行で定義されています。
const size_t kMaxThreadCacheSize = 2 << 20 [static] |
tcmalloc-0.93/tcmalloc.cc の 206 行で定義されています。
const Length kMaxValidPages = (~static_cast<Length>(0)) >> kPageShift [static] |
tcmalloc-0.93/tcmalloc.cc の 627 行で定義されています。
const int kMinSystemAlloc = 1 << (20 - kPageShift) [static] |
tcmalloc-0.93/tcmalloc.cc の 188 行で定義されています。
const size_t kMinThreadCacheSize = kMaxSize * 2 [static] |
tcmalloc-0.93/tcmalloc.cc の 205 行で定義されています。
const size_t kNumClasses = 68 [static] |
tcmalloc-0.93/tcmalloc.cc の 176 行で定義されています。
const int kNumTransferEntries = kNumClasses [static] |
tcmalloc-0.93/tcmalloc.cc の 303 行で定義されています。
const size_t kPageMapBigAllocationThreshold = 128 << 20 [static] |
tcmalloc-0.93/tcmalloc.cc の 180 行で定義されています。
const size_t kPageShift = 12 [static] |
tcmalloc-0.93/tcmalloc.cc の 171 行で定義されています。
const size_t kPageSize = 1 << kPageShift [static] |
tcmalloc-0.93/tcmalloc.cc の 172 行で定義されています。
uint64_t metadata_system_bytes = 0 [static] |
tcmalloc-0.93/tcmalloc.cc の 547 行で定義されています。
TCMallocGuard module_enter_exit_hook [static] |
tcmalloc-0.93/tcmalloc.cc の 2588 行で定義されています。
int num_objects_to_move[kNumClasses] [static] |
tcmalloc-0.93/tcmalloc.cc の 195 行で定義されています。
size_t overall_thread_cache_size = kDefaultOverallThreadCacheSize [static] |
tcmalloc-0.93/tcmalloc.cc の 1622 行で定義されています。
SpinLock pageheap_lock(SpinLock::LINKER_INITIALIZED) [static] |
char pageheap_memory[sizeof(TCMalloc_PageHeap)] [static] |
tcmalloc-0.93/tcmalloc.cc の 1589 行で定義されています。
size_t pagesize = 0 [static] |
tcmalloc-0.93/tcmalloc.cc の 3077 行で定義されています。
volatile size_t per_thread_cache_size = kMaxThreadCacheSize [static] |
tcmalloc-0.93/tcmalloc.cc の 1628 行で定義されています。
bool phinited = false [static] |
tcmalloc-0.93/tcmalloc.cc の 1590 行で定義されています。
unsigned int primes_list[] [static] |
初期値:
{ 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 4194319, 8388617, 16777259, 33554467 }
tcmalloc-0.93/tcmalloc.cc の 216 行で定義されています。
size_t sample_period = 262147 [static] |
tcmalloc-0.93/tcmalloc.cc の 238 行で定義されています。
SpinLock sample_period_lock(SpinLock::LINKER_INITIALIZED) [static] |
Span sampled_objects [static] |
tcmalloc-0.93/tcmalloc.cc の 763 行で定義されています。
SpinLock set_new_handler_lock(SpinLock::LINKER_INITIALIZED) [static] |
const int shift_amount[2] = { 3, 7 } [static] |
tcmalloc-0.93/tcmalloc.cc の 275 行で定義されています。
PageHeapAllocator<Span> span_allocator [static] |
tcmalloc-0.93/tcmalloc.cc の 682 行で定義されています。
PageHeapAllocator<StackTrace> stacktrace_allocator [static] |
tcmalloc-0.93/tcmalloc.cc の 762 行で定義されています。
tcmalloc-0.93/tcmalloc.cc の 1733 行で定義されています。
int thread_heap_count = 0 [static] |
tcmalloc-0.93/tcmalloc.cc の 1619 行で定義されています。
TCMalloc_ThreadCache* thread_heaps = NULL [static] |
tcmalloc-0.93/tcmalloc.cc の 1618 行で定義されています。
tcmalloc-0.93/tcmalloc.cc の 1615 行で定義されています。
bool tsd_inited = false [static] |
tcmalloc-0.93/tcmalloc.cc の 1611 行で定義されています。