Re: Memory Leak
Re: Memory Leak
- Subject: Re: Memory Leak
- From: Marshall Clow <email@hidden>
- Date: Mon, 26 May 2008 12:03:13 -0700
At 2:31 PM -0400 5/26/08, Jim Witte wrote:
On May 26, 2008, at 12:52 PM, MacArthur, Ian (SELEX GALILEO, UK) wrote:
Well, not necessarily. For example, if you have a large number of C++
objects, then you can call the destructors on exit. Or you can just
exit.
Calling the destructors takes time (often a significant amount, like 20
seconds or so.)
Marshall Clow wrote:
Lots of stuff happens after main () exits. (especially in C++)
Destructors for global objects run. A leak detector needs to check
after that.
Are destructors always run
Yes - barring abnormal termination (a crash, or a call to abort ()).
(or run in the same way if called explicitly by the programmer or by
the OS itself)?
In general, destructors are not called explicitly by the programmer.
They are called by the C++ runtime when the objects are destroyed.
For local variables, this is when the function exits. For objects on
the heap, this is when the memory is deallocated. For global
variables, this is when the program is shutting down.
If so, it would seem like any delay the destructors take to run
would happen no matter whether the programmer explicitly clean up
the objects or just lets the OS do it anyway.
Yes, that's true.
If your destructors are taking a long time (and 20 seconds at program
exit is a long time), then Shark is your friend - it can tell you how
the CPU is spending all that time....
--
-- Marshall
Marshall Clow Idio Software <mailto:email@hidden>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden