Search code examples

Memory usage isn't decreasing when using free?

Somehow this call to free() is not working. I ran this application on Windows and followed the memory using in Task Manager, but saw no reduction in memory usage after the call to free().

int main(int argc, char *argv[])
    int i=0;
    int *ptr;

    ptr = (int*) malloc(sizeof(int) * 1000);

    for (i=0; i < 1000; i++)
        ptr[i] = 0;

    free(ptr); // After this call, the program memory usage doesn't decrease


    return 0;


  • Typical C implementations do not return free:d memory to the operating system. It is available for use by the same program, but not to others.