What is a memory leak in structures? How can we rectify that?
Answer Posted / selvaraj
unwanted memory consumed by a program is called memory leak.
Example:
int fact(void)
{
size=melloc(20);
if(size==NULL)
{
return 1;
}
else
{
return 0;
}
}
Explanation:
size=melloc(20);
here the memory reserved
if(size==NULL)
if memory not available
else means memory available return 0
so, throughout the program the size never used but the program reserved the size. this is called memory leak..
to over come this problem in the else part before return 0; add this statement free(s)
Hope you understood. if not u can reach me iamselvam85@gmail.com
Is This Answer Correct ? | 13 Yes | 2 No |
Post New Answer View All Answers
Why c is a mother language?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
Are c and c++ the same?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What does s c mean on snapchat?
Why c language?
What is operator promotion?
How can I make it pause before closing the program output window?
Explain setjmp()?
What is the collection of communication lines and routers called?
Explain how do you generate random numbers in c?
What is ctrl c called?
How can I get back to the interactive keyboard if stdin is redirected?
Why c is a procedural language?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?