Check out example codes for "what are the causes of memory leaks in c". It will help you in understanding the concepts better.
Code Example 1
//If an exception is raised between allocation and deallocation, memory leak will occur.
void f1() {
int* ptr = new int;
// do something which may throw an exception
// we never get here if an exception is thrown
delete ptr;
}
Learn ReactJs, React Native from akashmittal.com