Re: Memory Leak
Re: Memory Leak
- Subject: Re: Memory Leak
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 24 May 2008 10:42:47 -0700
On May 24, 2008, at 2:38 AM, Romain Marucchi wrote:
How can I track all the memory leak of my C/C++ application when the
application close. I would like to have a list of all "not
deallocated" memory and where I initialize them... I check with
Instruments (Beta 5) and MallocDebug, but both of them doesn't show
me any memory leak when my application close... even if I create
some on purpose... am I doing something wrong?
Probably not. The tools aren't generally designed to capture the
state of an application when it closes because memory leaks at that
point in time are generally completely irrelevant; the system will
reclaim the memory of an application when it quits in its entirety.
However, there are cases where you might need to know. For example,
testing for memory leaks at the end of a unit test run is often a
great way to find leaks in framework code.
To these ends, I usually just add a sleep() to my main() function that
can be controlled via an environment variable...
int main(...) {
... do lots of stuff ...
if (getenv("PAUSEBEFOREEXIT")) {
// the time it takes light to travel from the sun to mars and back
// coincidentally, more than enough time to track down memory problems
sleep(760 * 2);
}
exit(n);
}
b.bum
_______________________________________________
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
References: | |
| >Memory Leak (From: Romain Marucchi <email@hidden>) |