• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Memory Leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Memory Leak
      • From: "Sean McBride" <email@hidden>
    • Re: Memory Leak
      • From: "Sean McBride" <email@hidden>
References: 
 >Memory Leak (From: Romain Marucchi <email@hidden>)

  • Prev by Date: Re: Porting windows app to OS X and it's extremely huge as a result
  • Next by Date: Re: using a dylib in the appfile.app/Contents/Frameworks?
  • Previous by thread: Memory Leak
  • Next by thread: Re: Memory Leak
  • Index(es):
    • Date
    • Thread