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 |
if p is a string contained in a string?
What are local static variables?
When should I declare a function?
How can I convert integers to binary or hexadecimal?
What happens if you free a pointer twice?
What is union and structure?
When is a void pointer used?
WHAT IS C?
how can use subset in c program and give more example
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
0 Answers College School Exams Tests,
Hai friends im a i year student. i want to develop my knowledge in the field of TSR in c. How I'm Improve ?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration