What is a memory leak and how can it be avoided?


Posted On: Feb 22, 2018


Memory leak is a condition when a programmer who creates a memory in the heap forgets to delete it. It can be avoided by using the following coding:

/* Function without memory leak */
#include < stdlib.h > 
void f() 
   int *ptr = (int *) malloc(sizeof(int));  
   /* Do some work */  

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Appcelerator Interview Questions

    What is Appcelerator?

    Appcelerator is a mobile development stage specially designed for big enterprises..

    Appcelerator Interview Questions

    How does Appcelerator work?

    Appcelerator is a code interpreter. A developer firstly writes code using the conventional Javascript and then compiles it using an application..

    Appcelerator Interview Questions

    How is Appcelerator different from other mobile application developers?

    Appcelerator has the capability to develop a native application using simple HTML codes within an application that gives it an edge over other mobile application developers..