What is Memory Leak? How can we avoid?
Memory leak occurs when programmers create a memory in heap and forget to delete it.
The consequences of memory leak is that it reduces the performance of the computer by reducing the amount of available memory. Eventually, in the worst case, too much of the available memory may become allocated and all or part of the system or device stops working correctly, the application fails, or the system slows down vastly .
Memory leaks are particularly serious issues for programs like daemons and servers which by definition never terminate.
To avoid memory leaks, memory allocated on heap should always be freed when no longer needed.
Program to Check whether the Memory is Freed or Not.