what is memory leak?

Answers were Sorted based on User's Feedback

what is memory leak? ..

Answer / roshan.p.r.

Consider the following example..

int *p=new int[10];

here ten bytes of memory is allocated and the address is
stored in p. the only way to access this memory is via p.

now suppose if u allocate a new memory to p like

p=new int[20];

the previous address(10 bytes is lost we cant access it
again)because the only way that we had to access it was
pointer p and now a new address(20 bytes) is stored in p.

So we say there is a memory leak.

the best way to handle this is.

int *p=new int[10];
[]delete p;
p=new int[20];

so in the above case we have first released the memory
pointed by p with delete function and then a new address is
assigned to it.

Is This Answer Correct ?    1 Yes 0 No

what is memory leak? ..

Answer / sujith

Memory leak is nothing but u create huge chunk of memory
with a malloc or any such mechanism and u never free that
manually which make the available free main memory in the
system to minimum. this may even lead to system crashing.

Is This Answer Correct ?    1 Yes 1 No

what is memory leak? ..

Answer / tayyab

When two object create a reference to each other. memory
allocated to these objects can not be reclaimed by
operating system even after when all other references are
deleted for these objects.....this concept is called memory

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

wat are the two methods for swapping two numbers without using temp variable??

2 Answers  

write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

0 Answers   Lovely Professional University,

What is the difference function call by value & function call by reference?

6 Answers  

Hi, main() { } Is a user defined function or Built in Functionn

26 Answers   Honeywell, Yahoo,

How to implement call back functions ?

3 Answers   HP,

main is a predefined or user define function if user defined why? if predefined whay?

12 Answers   TCS,

what is function pointer?

2 Answers   Wipro,

what is the difference between i++ and ++i?

5 Answers  

What is the code for 3 questions and answer check in VisualBasic.Net?

0 Answers   Infosys,

how to add numbers without using arithmetic operators.

14 Answers   TCS,

marge linklist

0 Answers   HCL,

What is the proper way of these job Tell me about there full work

0 Answers   EDS,