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
What are # preprocessor operator in c?
Explain the advantages of using macro in c language?
what are the facialities provided by you after the selection of the student.
What does sizeof function do?
What is optimization in c?
What is the meaning of ?
What is extern storage class in c?
What is difference between %d and %i in c?
What is getch() function?
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
Write a program to know whether the input number is an armstrong number.
What is else if ladder?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
Why should I use standard library functions instead of writing my own?
What are the different types of pointers used in c language?