• 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: 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


References: 
 >Re: Memory Leak (From: "MacArthur, Ian (SELEX GALILEO, UK)" <email@hidden>)
 >Re: Memory Leak (From: Jim Witte <email@hidden>)

  • Prev by Date: Re: Memory Leak
  • Next by Date: Creating a new XCode Project...help!
  • Previous by thread: Re: Memory Leak
  • Next by thread: Re: Memory Leak
  • Index(es):
    • Date
    • Thread