Pranit Kothari
Pranit Kothari

Reputation: 9839

Why only three memory addresses are shown in memory leak?

I have written following code to intentionally create memory leak.

#include <windows.h>

int main(int argc, char* argv[])
{
    while(1)
    {
        char *ch1 = new char[10];
        char *ch2 = new char[5];
        char *ch3 = new char[2];
        Sleep(5);
    }
    return 0;
}

I have taken logs using LeakDiag and make following graph using LDGrapher.

Now, my question is why only three address are shown in leak graph? I am keep on creating new pointers in while(1), so I am leaking memory at lots of addresses?

enter image description here

Upvotes: 2

Views: 532

Answers (1)

KrazyGautam
KrazyGautam

Reputation: 2692

Inclusion of windows.h "i assume u r running this on a windows box" *memory managament in windows is much smart as compared to linux .

Try running the same program in linux and redraw the graph to see the differece

Upvotes: 0

Related Questions