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 |
Why is c so important?
Write a program of prime number using recursion.
1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array?
how to print "hai" in c?
What is the difference between array_name and &array_name?
Explain how can I make sure that my program is the only one accessing a file?
WHO WROTE C LANGUAGE?
What is unary operator?
What are types of preprocessor in c?
#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?
Write a C program to convert an integer into a binary string?
what are enumerations in C