Categories
Technical

Memory leak

When memory is allocated using malloc() in any function ,it returns a pointer to the start of the data………and again we free the memory using free() wit the help of pointer.but it should be used b4 we leave the function.n if it’s not used the pointer is lost and there is no way to clr the memory and it can never be used.
tis is called MEMORY LEAK………

For example:

#include
#include
int main()
{
char *ptr;
ptr = NULL;
ptr = strdup(“HI”);
printf(“\n%s”,ptr);
// free(ptr);
// ptr = NULL;
return 0;
}

It will show memory leak of 3 bytes.
now Uncomment the commented lines, no memory leak will be there.

Categories
Entertainment

Getting bored at home !

Am getting bored in my home… So here after I thought of writing a little about me here…Today 2007/12/17 3:47 pm I have started writing my first blog… I hope it will continue…Don’t get scared on my pages… Have fun…