What is Memory Leak? Discuss the importance.
What is Memory Leak? First we have to understand memory management. Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs like daemons and servers Memory leakage occurs in C++ when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs in C++ by using wrong delete operator. The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values. In c /* Function with memory leak */ #include <stdlib.h> void f () { int *ptr = ( int *) malloc ( sizeof ( int )); /* Do some work */ return ; /* Return without freeing ptr*/ } In c++ // Program with memory leak #include <bits/stdc++.h> using ...