Just a high level info in simple words.
Whenever our application needs memory, it requests the Operating System because OS is the resource manager who takes care of sharing the valuable resources like CPU time & RAM among all the processes in a fair manner.
So when an application requests the OS for memory, the OS TAGS that memory location signifying that no other process is supposed to use this memory. And when we free this memory, the OS UNTAGS it so that it can be used by other processes. Now guess what happens if we forget to free this memory after our job is done??
This memory is left useless & wasted. Now since this memory is TAGGED, the OS cannot allocate this to any other process. This is called memory leak where the memory is only reserved but not used.
So to avoid this, the best practice is to run your code with valgrind / purify as suggested by Harshita.
Hope this helps!!