Multithreaded Memory Allocators for C/C++

I’ve used tcmalloc and read about Hoard. Both have similar implementations and both achieve roughly linear performance scaling with respect to the number of threads/CPUs (according to the graphs on their respective sites). So: if performance is really that incredibly crucial, then do performance/load testing. Otherwise, just roll a dice and pick one of the … Read more

Segfaults in malloc() and malloc_consolidate()

From http://www.gnu.org/s/libc/manual/html_node/Heap-Consistency-Checking.html#Heap-Consistency-Checking: Another possibility to check for and guard against bugs in the use of malloc, realloc and free is to set the environment variable MALLOC_CHECK_. When MALLOC_CHECK_ is set, a special (less efficient) implementation is used which is designed to be tolerant against simple errors, such as double calls of free with the same … Read more

How to use realloc in a function in C

You want to modify the value of an int* (your array) so need to pass a pointer to it into your increase function: void increase(int** data) { *data = realloc(*data, 5 * sizeof int); } Calling code would then look like: int *data = malloc(4 * sizeof *data); /* do stuff with data */ increase(&data); … Read more

alloc, malloc, and alloca — What’s the difference?

alloc() is not a standard C library function. Some older compilers and libraries contain an <alloc.h> library which provides some memory allocation functions, but this is not standard. The Microsoft Visual C++ runtime includes an Alloc() function which is somewhat similar to malloc(), but this is also not part of the C standard. malloc() allocates … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)