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=0;
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
leak

Is This Answer Correct ?    0 Yes 1 No



Post New Answer



More C Interview Questions

WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1 Answers   IBM,


what is the mean of c languages.

1 Answers   Polaris,


what is an inline fuction??

2 Answers  


Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++;

5 Answers   Wipro, ITCO,


64/square(4)

1 Answers  






i want to have a program to read a string and print the frequency of each character and it should work in turbo c

3 Answers   Wipro, Persistent,


My teacher ask to make a program that can: Insert record in front Insert record at the end Insert in between Search node record Delete record in front Delete record at the end Delete record in between Using Data structure Linked List type. But I'm really confused about the codes and I can't go through. Please help Thanks in advance. Also here is my unfinished code if someone can make changes it will be more good.

1 Answers  


write a program in c language to print your bio-data on the screen by using functions.

0 Answers  


how can we use static and extern?and where can we use this?

3 Answers   Excel,


what is a headerfile?and what will be a program without it explain nan example?

6 Answers   Assurgent,


Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?

7 Answers  


What is the difference between void main() and void main (void) give example programme?

0 Answers  






Categories