473,774 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exit() and Memory leak reported

Hi all, quick question. I have an application I'm running. There are some
"fatal" error conditions that could occur during processing, and I want to
exit immediately if one comes up. When I put an exit() function call in my
code I get a message like this:

Detected memory leaks!
Dumping objects ->
{177} normal block at 0x003864E8, 32 bytes long.
Data: <c:\polling\inb ou> 63 3A 5C 70 6F 6C 6C 69 6E 67 5C 69 6E 62 6F 75

With about 20 lines after the "Dumping objects->" line. If I put an exit()
function call immediately before the return statement in main(), it gives me
a message like the above but with only two lines after "Dumping objects->".

Finally, if I remove all exit() function calls and let it run all the way
through to the return in main(), no memory leak is reported and it
terminates normally. My question is should I be worried about this? And if
so, what can I do about it? The "memory leak" only seems to appear when I
terminate the code early, and does not appear as bad if I terminate later in
the application. Any ideas are welcome.

Thanks!
Jun 13 '06 #1
4 1365
Oh yeah, I also noticed the "Data:" lines it's reporting in the object dump
match up exactly with the data for a bunch of static std::string public
variables in a class I created, if that makes a difference. Thanks.

"Mike C#" <xy*@xyz.com> wrote in message
news:uh******** ******@TK2MSFTN GP03.phx.gbl...
Hi all, quick question. I have an application I'm running. There are
some "fatal" error conditions that could occur during processing, and I
want to exit immediately if one comes up. When I put an exit() function
call in my code I get a message like this:

Detected memory leaks!
Dumping objects ->
{177} normal block at 0x003864E8, 32 bytes long.
Data: <c:\polling\inb ou> 63 3A 5C 70 6F 6C 6C 69 6E 67 5C 69 6E 62 6F 75

With about 20 lines after the "Dumping objects->" line. If I put an
exit() function call immediately before the return statement in main(), it
gives me a message like the above but with only two lines after "Dumping
objects->".

Finally, if I remove all exit() function calls and let it run all the way
through to the return in main(), no memory leak is reported and it
terminates normally. My question is should I be worried about this? And
if so, what can I do about it? The "memory leak" only seems to appear
when I terminate the code early, and does not appear as bad if I terminate
later in the application. Any ideas are welcome.

Thanks!

Jun 13 '06 #2
"Mike C#" <xy*@xyz.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Oh yeah, I also noticed the "Data:" lines it's reporting in the object
dump match up exactly with the data for a bunch of static std::string
public variables in a class I created, if that makes a difference.
Thanks.

I obviously don't have your code at hand, but this is expected behavior.
while you are debugging, the memory allocator keeps track of all
allocations.

each allocation that is not deallocated at the time of exit is considered
leaked.
by explicitly calling exit, you terminate your program without normal
deallocations.
As a result, anthying not de-allocated at that point is reported as a leak.

the destructor of your static strings is not executed until after the very
last return.
that explains why that is the only data reported as being leaked at that
point.

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Jun 13 '06 #3

"Bruno van Dooren" <br************ **********@hotm ail.com> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
"Mike C#" <xy*@xyz.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I obviously don't have your code at hand, but this is expected behavior.
while you are debugging, the memory allocator keeps track of all
allocations.

each allocation that is not deallocated at the time of exit is considered
leaked.
by explicitly calling exit, you terminate your program without normal
deallocations.
As a result, anthying not de-allocated at that point is reported as a
leak.

the destructor of your static strings is not executed until after the very
last return.
that explains why that is the only data reported as being leaked at that
point.


Thanks Bruno, that's what I suspected but wasn't sure. I've double-checked
everything and there don't appear to be any 'real' memory leaks. It just
threw me off to see that warning while debugging. Do you know of any way to
avoid that message? I.e., is there a way to force it to force that memory
leak check to wait until after the static strings are deallocated or is that
just something I have to live with?

Thanks
Jun 13 '06 #4
"Mike C#" <xy*@xyz.com> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..

"Bruno van Dooren" <br************ **********@hotm ail.com> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
"Mike C#" <xy*@xyz.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I obviously don't have your code at hand, but this is expected behavior.
while you are debugging, the memory allocator keeps track of all
allocations.

each allocation that is not deallocated at the time of exit is considered
leaked.
by explicitly calling exit, you terminate your program without normal
deallocations.
As a result, anthying not de-allocated at that point is reported as a
leak.

the destructor of your static strings is not executed until after the
very last return.
that explains why that is the only data reported as being leaked at that
point.

Thanks Bruno, that's what I suspected but wasn't sure. I've
double-checked everything and there don't appear to be any 'real' memory
leaks. It just threw me off to see that warning while debugging. Do you
know of any way to avoid that message? I.e., is there a way to force it
to force that memory leak check to wait until after the static strings are
deallocated or is that just something I have to live with?


Don't worry about any memory leaks that appear only when exit is called --
ExitProcess frees them.

Really, you aren't much concerned about static objects either, they consume
a fixed amount of space. It's the allocation-in-a-loop or periodic
allocation that isn't freed that causes problems. The memory toolkit
provides a feature (called snapshot or checkpoint) which you can call after
your startup code completes, and then again after performing some task, to
make sure that the task code cleaned up after itself properly.

Thanks

Jun 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2232
by: Newbie | last post by:
We have a web application in AS. It also uses COM+ and SQL Server as back-end. Sometimes the size of the dllhost.exe grows unexpectedly. It is such that we restart our IIS/ PWS. Also there is only one instance of dllhost running when we restart the webserver but later on we notice more than one instance sometimes. Please suggest.
4
2351
by: Morten Aune Lyrstad | last post by:
Ok, now I'm officially confused. I have a large project going, which uses a win32 ui library I am developing myself. And I'm getting weird memory leaks. I don't know if I can explain what is going on, but I really need some help on this one. Ok, so I have this class defined (written by Randy Charles Morin, www.kbcafe.com) which detects memory leaks. It creates a memory check point in the constructor, and another in the destructor, and...
2
1400
by: Fred | last post by:
Hi, I came across code which stores class pointers in an array. I have simplified it below. When I run the code I get a memory leak reported in VC6. Any idea why and is it something to worry about or just an artifact of the debugger? class CTest
7
6936
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports the status of the machines. Upon we follow the .NET object lifetime recommendations the application is constantly consuming more memory! The problem is on the ManagementObjectSearch, upon we Dispose the object it seems that is not releasing the...
3
5327
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". Anybody know anything about this? Does *Javascript* leak memeory, or does the *browser* leak memory?
9
2345
by: benoit808 | last post by:
I don't have a lot of experience with C++ so I apologize if this is a stupid question. I use Paul Nettle's memory manager (mmgr.cpp) which reports a memory leak but I don't think there's one. Here is the code (i took some stuff out to simplify): void myFunction() { Sprite *pImage; sprintf(pStr, "s04-%02d.png", i);
17
2548
by: Mike | last post by:
Hello, I have following existing code. And there is memory leak. Anyone know how to get ride of it? function foo has been used in thousands places, the signature is not allowed to change. Thanks in advance,
8
4169
by: BillE | last post by:
I have an existing asp.net 2.0 webforms app using master/content pages, and it works fine. I added some Ajax elements, including some UpdatePanels and modal PopUp panels which contain asp.net controls like gridviews with selectable rows, buttons, textboxes. I'm using Ajax 1.0, and the users are still using IE 6. Some heavy users reported that the application starts to run slowly after a while, and task manager shows the memory usage...
22
9364
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a memory leak someplace. I can not detect the memory leak by running several reports by hand, but when I run tha app as a servrice and process few hundred reports there is significant memory leak. The application can consume over 1GB of memory where it...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.