Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How can I delete a file?

1072


What is the general form of #line preprocessor?

1006


What is the difference between break and continue?

1550


Why is sprintf unsafe?

1086


Is boolean a datatype in c?

1076


Why C language is a procedural language?

1048


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1980


Can a variable be both constant and volatile?

1134


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

3269


How can I make it pause before closing the program output window?

1048


What is the use of a ‘’ character?

1100


Why doesnt long int work?

1052


Is flag a keyword in c?

1161


What are the 4 types of organizational structures?

1110


Write a C program to count the number of email on text

1923