STXXL
1.4-dev
|
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <clocale>
#include <dlfcn.h>
#include <stxxl/bits/config.h>
#include <stxxl/bits/utils/malloc_count.h>
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE |
#define | INIT_HEAP_SIZE 1024 * 1024 |
#define | PPREFIX "malloc_count ### " |
#define | THREAD_SAFE_GCC_INTRINSICS STXXL_HAVE_SYNC_ADD_AND_FETCH |
Typedefs | |
typedef void(* | free_type )(void *) |
typedef void *(* | malloc_type )(size_t) |
typedef void *(* | realloc_type )(void *, size_t) |
Functions | |
static | __attribute__ ((constructor)) void init(void) |
static | __attribute__ ((destructor)) void finish(void) |
void * | calloc (size_t nmemb, size_t size) throw () |
static void | dec_count (size_t dec) |
void | free (void *ptr) throw () |
static void | inc_count (size_t inc) |
void * | malloc (size_t size) throw () |
size_t | malloc_count_current (void) |
size_t | malloc_count_peak (void) |
void | malloc_count_print_status (void) |
void | malloc_count_reset_peak (void) |
void | malloc_count_set_callback (malloc_count_callback_type cb, void *cookie) |
void * | realloc (void *ptr, size_t size) throw () |
Variables | |
static const size_t | alignment = 16 |
static malloc_count_callback_type | callback = NULL |
static void * | callback_cookie = NULL |
static long long | curr = 0 |
static char | init_heap [1024 *1024] |
static size_t | init_heap_use = 0 |
static const int | log_operations = 1 |
static const int | log_operations_init_heap = 0 |
static const size_t | log_operations_threshold = 1024 * 1024 |
static long long | peak = 0 |
static free_type | real_free = NULL |
static malloc_type | real_malloc = NULL |
static realloc_type | real_realloc = NULL |
static const size_t | sentinel = 0xDEADC0DE |
static long long | total = 0 |
#define _GNU_SOURCE |
Definition at line 19 of file malloc_count.cpp.
#define INIT_HEAP_SIZE 1024 * 1024 |
Definition at line 55 of file malloc_count.cpp.
Referenced by malloc().
#define PPREFIX "malloc_count ### " |
Definition at line 61 of file malloc_count.cpp.
Referenced by __attribute__(), free(), malloc(), malloc_count_print_status(), and realloc().
#define THREAD_SAFE_GCC_INTRINSICS STXXL_HAVE_SYNC_ADD_AND_FETCH |
Definition at line 36 of file malloc_count.cpp.
typedef void(* free_type)(void *) |
Definition at line 44 of file malloc_count.cpp.
typedef void*(* malloc_type)(size_t) |
Definition at line 43 of file malloc_count.cpp.
typedef void*(* realloc_type)(void *, size_t) |
Definition at line 45 of file malloc_count.cpp.
|
static |
Definition at line 313 of file malloc_count.cpp.
References PPREFIX, real_free, real_malloc, and real_realloc.
|
static |
void* calloc | ( | size_t | nmemb, |
size_t | size | ||
) | |||
throw | ( | ||
) |
Definition at line 225 of file malloc_count.cpp.
References malloc().
|
static |
Definition at line 88 of file malloc_count.cpp.
References callback, callback_cookie, and curr.
void free | ( | void * | ptr | ) | |
throw | ( | ||||
) |
Definition at line 184 of file malloc_count.cpp.
References alignment, curr, dec_count(), init_heap, init_heap_use, log_operations, log_operations_init_heap, log_operations_threshold, PPREFIX, real_free, and sentinel.
Referenced by stxxl::aligned_alloc(), stxxl::aligned_dealloc(), stxxl::binary_buffer::dealloc(), stxxl::mem_file::discard(), stxxl::print_stacktrace(), realloc(), and stxxl::mem_file::~mem_file().
|
static |
Definition at line 73 of file malloc_count.cpp.
References callback, callback_cookie, curr, peak, and total.
void* malloc | ( | size_t | size | ) | |
throw | ( | ||||
) |
Definition at line 137 of file malloc_count.cpp.
References alignment, curr, inc_count(), init_heap, INIT_HEAP_SIZE, init_heap_use, log_operations, log_operations_init_heap, log_operations_threshold, PPREFIX, real_malloc, and sentinel.
Referenced by stxxl::aligned_alloc(), calloc(), stxxl::mem_file::discard(), stxxl::print_stacktrace(), and realloc().
size_t malloc_count_current | ( | void | ) |
Definition at line 100 of file malloc_count.cpp.
References curr.
size_t malloc_count_peak | ( | void | ) |
Definition at line 106 of file malloc_count.cpp.
References peak.
void malloc_count_print_status | ( | void | ) |
Definition at line 118 of file malloc_count.cpp.
void malloc_count_reset_peak | ( | void | ) |
Definition at line 112 of file malloc_count.cpp.
void malloc_count_set_callback | ( | malloc_count_callback_type | cb, |
void * | cookie | ||
) |
Definition at line 125 of file malloc_count.cpp.
References callback, and callback_cookie.
void* realloc | ( | void * | ptr, |
size_t | size | ||
) | |||
throw | ( | ||
) |
Definition at line 236 of file malloc_count.cpp.
References alignment, curr, dec_count(), free(), inc_count(), init_heap, init_heap_use, log_operations, log_operations_init_heap, log_operations_threshold, malloc(), PPREFIX, and sentinel.
Referenced by stxxl::aligned_alloc(), stxxl::binary_buffer::alloc(), and stxxl::mem_file::set_size().
|
static |
Definition at line 40 of file malloc_count.cpp.
|
static |
Definition at line 69 of file malloc_count.cpp.
Referenced by dec_count(), inc_count(), and malloc_count_set_callback().
|
static |
Definition at line 70 of file malloc_count.cpp.
Referenced by dec_count(), inc_count(), and malloc_count_set_callback().
|
static |
Definition at line 67 of file malloc_count.cpp.
Referenced by __attribute__(), stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::_erase_nodes(), stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::_find_key_internal(), dec_count(), stxxl::stream::basic_runs_creator< stream::use_push< ValueType >, cmp_type, BlockSize, alloc_strategy_type >::fill_with_max_value(), stxxl::stream::runs_creator< use_push< ValueType >, CompareType, BlockSize, AllocStr >::fill_with_max_value(), free(), inc_count(), malloc(), malloc_count_current(), malloc_count_print_status(), malloc_count_reset_peak(), realloc(), and stxxl::vector_bufreader< VectorIteratorType >::rewind().
|
static |
Definition at line 56 of file malloc_count.cpp.
|
static |
Definition at line 57 of file malloc_count.cpp.
|
static |
Definition at line 32 of file malloc_count.cpp.
|
static |
Definition at line 58 of file malloc_count.cpp.
|
static |
Definition at line 33 of file malloc_count.cpp.
|
static |
Definition at line 67 of file malloc_count.cpp.
Referenced by __attribute__(), inc_count(), malloc_count_peak(), malloc_count_print_status(), and malloc_count_reset_peak().
|
static |
Definition at line 48 of file malloc_count.cpp.
Referenced by __attribute__(), and free().
|
static |
Definition at line 47 of file malloc_count.cpp.
Referenced by __attribute__(), and malloc().
|
static |
Definition at line 49 of file malloc_count.cpp.
Referenced by __attribute__().
|
static |
Definition at line 52 of file malloc_count.cpp.
Referenced by stxxl::priority_queue_local::int_merger< value_type, comparator_type, IntKMAX >::append_array(), stxxl::priority_queue_local::loser_tree< ValueType, CompareType, MaxArity >::compactTree(), stxxl::priority_queue_local::loser_tree< ValueType, CompareType, MaxArity >::deallocate_segment(), stxxl::priority_queue_local::loser_tree< ValueType, CompareType, MaxArity >::doubleK(), free(), stxxl::priority_queue_local::int_merger< value_type, comparator_type, IntKMAX >::free_array(), stxxl::priority_queue< ConfigType >::init(), stxxl::priority_queue_local::loser_tree< ValueType, CompareType, MaxArity >::init(), stxxl::priority_queue_local::int_merger< value_type, comparator_type, IntKMAX >::is_array_allocated(), stxxl::priority_queue_local::loser_tree< ValueType, CompareType, MaxArity >::is_segment_empty(), stxxl::priority_queue_local::int_merger< value_type, comparator_type, IntKMAX >::m_size(), stxxl::priority_queue_local::int_merger< value_type, comparator_type, IntKMAX >::make_array_sentinel(), malloc(), realloc(), stxxl::priority_queue_local::loser_tree< self_type, CompareType, MaxArity >::swap(), and stxxl::priority_queue_local::int_merger< value_type, comparator_type, IntKMAX >::swap().
|
static |
Definition at line 67 of file malloc_count.cpp.
Referenced by __attribute__(), stxxl::disk_allocator::dump(), stxxl::block_manager::get_free_bytes(), stxxl::block_manager::get_total_bytes(), and inc_count().