What is a memory leak in structures? How can we rectify that?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / sadhasivaraj
defining a structure includes lots of memory space bcoz
scructure consumes lots of memory space by allocatin a
desired space during initialization
ie bcoz struct can handle different data types
Is This Answer Correct ? | 4 Yes | 1 No |
in which language c language is written?
1.What is a Data Structure? Explain its need? 2.What is a Directed Graph? Write an algorithm to find whether a Directed Graph is connected or not? 3.Explain the process of converting a Tree to a Binary Tree.
What is the code for 3 questions and answer check in VisualBasic.Net?
write a function for strtok()??
Write a function to find the area of a triangle whose length of three sides is given
What is the difference between printf and scanf in c?
Identify the correct argument for the function call fflush () in ANSI C: A)stdout B)stdin C)stderr D)All the above
Differentiate between the expression “++a” and “a++”?
What is hungarian notation? Is it worthwhile?
What are reserved words?
What is dynamic variable in c?
What is the real difference between arrays and pointers?
27 Answers Hexaware, Logic Pro, TCS,