Solved

what is lost heap dynamic? and how it is created. explain indetail

Posted on 2016-08-22
3
14 Views
Last Modified: 2016-11-28
I had this question after viewing Find dangling pointer or lost heap-dynamic  variables..
0
Comment
Question by:priscilla ammisetti
3 Comments
 

Author Comment

by:priscilla ammisetti
ID: 41766313
tel me very fast pls
0
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
ID: 41766338
• Lost heap-dynamic variable (garbage)
– An allocated heap-dynamic variable that is no longer accessible to the user program
• Pointer p1 is set to point to a newly created heap-dynamic variable
• Pointer p1 is later set to point to another newly created heap dynamic variable
• We now have a memory leak
http://aturing.umcs.maine.edu/~meadow/courses/cos301/cos301-6b.pdf

If you say Type *ptr = new Type; and then say ptr = NULL;
then the allocation of the Type object is not longer available. The memory is still allocated on the heap, but the program has lost permanent access to it. It is just taking up memory and will not be released until the program ends.

In the above scenario, if you are in a loop doing the new and the ptr = NULL; then the program's memory usage keeps increasing as more Type objects are thrown away on the heap. You have to delete the Type object before setting ptr to NULL.
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41903858
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: phoffric (https:#a41766338)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maze travler 6 51
how to understand recursion 12 219
Writing a parser for java language 4 71
c++ using a LPCOLESTR * and adding a string varaible to the Pointer 2 49
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now