[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Debug and operator new

Posted on 1999-11-11
9
Medium Priority
?
168 Views
Last Modified: 2010-04-01
I am testing a utility in debug mode of
VC6. In the program I allocate some space from heap with new, But I dont follow the program to the end whre I
delete [], I stop the debug mode
with allocated memory. I want to
know if the memory allocated stays until I shot the computer or it releases when I stop debug mode.


Thank you.
This is important for me to know.
0
Comment
Question by:Info_user100
  • 4
  • 3
  • 2
9 Comments
 
LVL 4

Accepted Solution

by:
captainkirk earned 40 total points
ID: 2200678
If you allocated some memory with new(), it remains allocated until you delete() it or the process terminates. If the process terminates without your having called delete(), or you keep on allocating more memory without eventually releasing it, then you have what is known as a "memory leak".
0
 

Author Comment

by:Info_user100
ID: 2200737
What if The process is terminated the way I described it?
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2200744
same issue - if you stop debugging before the memory is released to the system, the debugger will flag this as a memory leak -- in other words, it remains allocated....
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:Info_user100
ID: 2200782
Thanks, but can you tell me where that flag is.
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2200792
When you stop the debug session, if there are memory leaks, the output window will say:

"Detected Memory Leaks!"

and proceed to dump all objects that you have allocated without releasing...
(I'm talking about Visual C++ 6.0, now...)
0
 

Author Comment

by:Info_user100
ID: 2200803
Points raised.

Than if I didnt see the window that you mention can it release without me even knowing it released it?
0
 
LVL 22

Expert Comment

by:nietod
ID: 2200857
Except you must turn that feature on.  by default it does not warn you of memory leaks.  So if you have not turned the feature on you will not see the leaks reported, even if there are some.
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2201218
nietod - this feature is already turned on (at least in VC++ 6.0) when building a debug target project... I have never had to do any special manipulations to get the dump... when debug is defined, mapping takes place to debug versions of memory management routines and everything. I'm curious why you have to do all this extra setup...
0
 
LVL 22

Expert Comment

by:nietod
ID: 2201239
   In VC 5 it definitly was not on by default.  i guess I never tested that in VC 6.  However, i'm not completely convinced you're right.  Do you use MFC?  MFC turns it on.  You have to test it by creating a leak in a non-MFC app to be sure.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

591 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