memory lead

buddy's Avatar, Join Date: Aug 2007
Go4Expert Member
what is mean by memory leak in c programming ?? can anyone explain with an example??plz.
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
If you allocate memory dynamically from the heap, then don't return it before the program exits, it's no longer available for other programs.
0
listendinesh's Avatar, Join Date: Aug 2007
Go4Expert Member
Here is the example

Code:
int main()
{
char *buffer1;
char *buffer2;
buffer1 = (char *)malloc(5*sizeof(char));
buffer2 = (char *)malloc(5*sizeof(char));
buffer1 = buffer2; // This will lead Memory leak
.
.
.
.
}