Using new and delete operator

In compile time allcation the allocation and dealllcation is done by the compiler when the main function call is over.
But in case of we forget to delete the memory allocation using the new keyboard but after the main() is over all the memory is going to delete then how there is memory leak?

hi @Vikaspal If a program has memory leaks, then its memory usage is satirically increasing since all systems have limited amount of memory and memory is costly. Hence it will create problems. That memory is no longer used by the program, but it is still allocated to it. Hence it is very important to free the memory. The memory you are talking about is the stack memory, dynamically allocated variables are present in the heap.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.