Solved

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

Posted on 2016-08-22
3
7 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
Comment Utility
tel me very fast pls
0
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
Comment Utility
• 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 13

Expert Comment

by:frankhelk
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 57
best sources to up-to-date in C++? 8 55
computer science syllabus 3 52
C++ mouse_event mouse look 7 19
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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

772 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

15 Experts available now in Live!

Get 1:1 Help Now