Q:

What is the memory leak in C?

0

What is the memory leak in C?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

A memory leak is a common and dangerous problem. It is a type of resource leak. In C language, a memory leak occurs when you allocate a block of memory using the memory management function and forget to release it.

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    char * pBuffer = malloc(sizeof(char) * 20);
    /* Do some work */
    return 0; /*Not freeing the allocated memory*/
}

Note: once you allocate a memory than allocated memory does not allocate to another program or process until it gets free.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

What is dynamic memory fragmentation?... >>
<< What is the return value of malloc (0)?...