Top "Malloc" questions

The malloc function performs dynamic memory allocation in C and is part of the standard library.

C++ memory allocation mechanism performance comparison (tcmalloc vs. jemalloc)

I have an application which allocates lots of memory and I am considering using a better memory allocation mechanism than …

c++ linux malloc tcmalloc
calloc v/s malloc and time efficiency

I've read with interest the post C difference between malloc and calloc. I'm using malloc in my code and would …

c optimization malloc calloc
Is there a need to check for NULL after allocating memory, when kernel uses overcommit memory

It is general practice to check for NULL (whether memory is successfully allocated) after a malloc(), some thing like void *…

memory malloc android-ndk
strtok and memory leaks

I wrote a simple url parser using strtok(). here's the code #include <stdio.h> #include <stdlib.h&…

c memory free malloc strtok
Time complexity of memory allocation

What is the time complexity of dynamic memory allocation using new, malloc, etc.? I know very little about how memory …

optimization memory-management malloc time-complexity
Malloc function (dynamic memory allocation) resulting in an error when it is used globally

#include<stdio.h> #include<string.h> char *y; y=(char *)malloc(40); // gives an error here int …

c malloc global-variables dynamic-memory-allocation
Proper Way to Free Memory of a Returned Variable

I created a function designed to get user input. It requires that memory be allocated to the variable holding the …

c memory malloc free
Will malloc implementations return free-ed memory back to the system?

I have a long-living application with frequent memory allocation-deallocation. Will any malloc implementation return freed memory back to the system? …

free malloc glibc mmap tcmalloc
Char ** usage and printing

In C, I am using a char ** to hold a series of strings. Here is my code: char ** c; //now …

c malloc multidimensional-array double-pointer
Is a malloc() needed before a realloc()?

Since I had read realloc will act as malloc if the size pointed is 0, I was using it without malloc(), …

c memory-management malloc alloc