• Register
100 points
7 2

C++ programming language uses the free() function to “free” the run-time allocated in the memory of the operating system. Basically, the function reallocates more memory, other functions use that memory. The parameters in free function are null or block of memory allocated, and denoted by a pointer to a memory (ptr) block previously allocated with malloc, calloc or realloc. If ptr is null, the free( ) function does nothing else; Malloc, calloc and realloc allocate a memory block. 


The double-free error occurs when free( ) is called over one time with the same memory. The program memory data structures become corrupted or altered, and an intruder like a hacker can write values in the memory spaces. A program can crash or alter execution flow. 

Corruption (Fasttop) error happens when memory blocks allocated on the runtime or on the stack or workspace used to manage the heap. The error is hard to detect because the memory is valid for reading and writing unlike double free. 

The memory corruption include

  • Register memory 

  • user virtual memory 


Errors related to memory allocations are messy to be handled. Look into the program and find out where you are calling free() function more than once within the same memory.

An easy fix will be for the Linux users. In Linux os there is a programming tool known as valgrind. By using valgrind you will easily get the statement where you are having memory allocation issues.

100 points
7 2