Skip to main content

malloc_counter.cpp File

Included Headers

#include "malloc_counter/malloc_counter.hpp" #include <dlfcn.h> #include <locale.h> #include <pthread.h> #include <stdatomic.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h>

Classes Index

structOriginalFunctions

Typedefs Index

usingmalloc_type = void *(size_t)
usingfree_type = void(void *)
usingrealloc_type = void *(void *, size_t)
usingcalloc_type = void *(size_t, size_t)

Functions Index

static boolisInitHeapPointer (const void *ptr)
size_tmalloc_count_current ()
size_tmalloc_count_peak ()
voidmalloc_count_reset_peak ()
size_tmalloc_count_num_allocs ()
voidmalloc_count_print_status ()
voidmalloc_count_set_callback (malloc_count_callback_type *, void *)
voidmalloc_count_start_monitoring ()
voidmalloc_count_stop_monitoring ()
size_tmalloc_count_thread_allocs ()
void *malloc (size_t size)
voidfree (void *ptr)
void *calloc (size_t nmemb, size_t size)
void *realloc (void *ptr, size_t size)
static static__attribute__ ((constructor)) void init()

Variables Index

static OriginalFunctionsoriginalFunctions
constexpr size_tinitHeapSize = 4096 * 4096
static charinitHeap[initHeapSize]
static size_tinitHeapUse = 0
static _Atomic size_ttotalNumAllocs = 0
static _Atomic uint64_tmonitoredThread = 0
static _Atomic size_tmonitoredAllocs = 0
static _Atomic intmonitoringActive = 0

Typedefs

calloc_type

using calloc_type = void*(size_t, size_t)

Definition at line 48 of file malloc_counter.cpp.

free_type

using free_type = void(void*)

Definition at line 46 of file malloc_counter.cpp.

malloc_type

using malloc_type = void*(size_t)

Definition at line 45 of file malloc_counter.cpp.

realloc_type

using realloc_type = void*(void*, size_t)

Definition at line 47 of file malloc_counter.cpp.

Functions

__attribute__()

__attribute__ ((constructor))
static

Definition at line 280 of file malloc_counter.cpp.

calloc()

void * calloc (size_t nmemb, size_t size)

Definition at line 207 of file malloc_counter.cpp.

free()

void free (void * ptr)

Definition at line 189 of file malloc_counter.cpp.

isInitHeapPointer()

bool isInitHeapPointer (const void * ptr)
static

Definition at line 70 of file malloc_counter.cpp.

malloc()

void * malloc (size_t size)

Definition at line 149 of file malloc_counter.cpp.

malloc_count_current()

size_t malloc_count_current ()

Definition at line 91 of file malloc_counter.cpp.

malloc_count_num_allocs()

size_t malloc_count_num_allocs ()

Definition at line 106 of file malloc_counter.cpp.

malloc_count_peak()

size_t malloc_count_peak ()

Definition at line 96 of file malloc_counter.cpp.

malloc_count_print_status()

void malloc_count_print_status ()

Definition at line 111 of file malloc_counter.cpp.

malloc_count_reset_peak()

void malloc_count_reset_peak ()

Definition at line 101 of file malloc_counter.cpp.

malloc_count_set_callback()

void malloc_count_set_callback (malloc_count_callback_type * cb, void * cookie)

Definition at line 116 of file malloc_counter.cpp.

malloc_count_start_monitoring()

void malloc_count_start_monitoring ()

Definition at line 122 of file malloc_counter.cpp.

malloc_count_stop_monitoring()

void malloc_count_stop_monitoring ()

Definition at line 134 of file malloc_counter.cpp.

malloc_count_thread_allocs()

size_t malloc_count_thread_allocs ()

Definition at line 139 of file malloc_counter.cpp.

realloc()

void * realloc (void * ptr, size_t size)

Definition at line 240 of file malloc_counter.cpp.

Variables

initHeap

char initHeap[initHeapSize]
static

Definition at line 67 of file malloc_counter.cpp.

initHeapSize

constexpr size_t initHeapSize = 4096 * 4096
constexpr

Definition at line 66 of file malloc_counter.cpp.

initHeapUse

size_t initHeapUse = 0
static

Definition at line 68 of file malloc_counter.cpp.

monitoredAllocs

_Atomic size_t monitoredAllocs = 0
static

Definition at line 87 of file malloc_counter.cpp.

monitoredThread

_Atomic uint64_t monitoredThread = 0
static

Definition at line 86 of file malloc_counter.cpp.

monitoringActive

_Atomic int monitoringActive = 0
static

Definition at line 88 of file malloc_counter.cpp.

originalFunctions

OriginalFunctions originalFunctions
static

Definition at line 58 of file malloc_counter.cpp.

totalNumAllocs

_Atomic size_t totalNumAllocs = 0
static

Definition at line 80 of file malloc_counter.cpp.


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.