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 |
Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.
What is modifier & how many types of modifiers available in c?
what is the maximum no. of bytes calloc can allocate
What are qualifiers in c?
What do you mean by a sequential access file?
Differentiate between null and void pointers.
What are the benefits of c language?
What are the different types of control structures?
Which weighs more, a gram of feathers or a gram of gold?
Can a pointer point to null?
What is the difference between far and near ?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database
2 Answers TCS, Unisys, Webyog,