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
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
What is c method?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
what is the difference between 123 and 0123 in c?
What is const volatile variable in c?
What are the ways to a null pointer can use in c programming language?
Do you know the difference between malloc() and calloc() function?
Explain that why C is procedural?
What is s or c?
What is sizeof return in c?
What is data structure in c language?
how to write a c program to print list of fruits in alpabetical order?
Is c a great language, or what?
What are the differences between Structures and Arrays?
When we use void main and int main?