Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   memory lead (http://www.go4expert.com/forums/memory-lead-t6281/)

buddy 10Sep2007 21:42

memory lead
 
what is mean by memory leak in c programming ?? can anyone explain with an example??plz.

DaWei 10Sep2007 21:51

Re: memory lead
 
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.

listendinesh 11Sep2007 10:23

Re: memory lead
 
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
.
.
.
.
}



All times are GMT +5.5. The time now is 09:35.