Memory leak is that when memory is allocated but its not released because of an application consume memory reducing the available memory for other applications and causing the system to page virtual memory to the hard drive showing the application or crashing the application. When the computer memory resource limits are reached.
Suppose, We have allocated 10 bytes to each MemoryArea and NewMemArea.
Now,If we execute the statement which is given below:
MemoryArea = NewMemArea
In this programmer has assigned the MemoryArea pointer to the NewMemArea pointer.So that,the memory location to which MemoryArea was pointing to earlier becomes an orphan. It cannot be freed, as there is no reference to this location. This will result in a memory leak of 10 bytes.
Before assigning the pointers, make sure memory locations are not becoming orphaned.