Answers for "what are the causes of memory leaks in c"

C
0

what are the causes of memory leaks in c

//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;
}
Posted by: Guest on May-20-2020

Code answers related to "what are the causes of memory leaks in c"

Code answers related to "C"

Browse Popular Code Answers by Language