• 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: Horst Hoesel <email@hidden>
  • Date: Tue, 27 May 2008 15:57:45 +0200

[snip]

On exit, the original author had written the code such that it
*explicitly* called the destructors for all the widgets he'd created.
When the user clicked the exit button, the app would take 20~30 seconds
to close, and at least one of the CPU's would max out during this time.
The code was modified to *not* explicitly call the destructors.
Thereafter, when the user clicked the exit button, the app would
terminate "straight away", with no CPU maxing out.


[snip]

In general when an OS (Mac OS X, Windows, Linux, ...) terminates a process no destructors are called. The OS reclaims assigned memory at a different/lower level than release, dealloc, free (or whatever your runtime model uses). So unless the destructores do things like saving object/program/data/preference state information to disk or tear down network connections orderly, there is no need to call them prior to program exit.


That said, it is good practice to call the destructors on exit, since not doing so implies the knowledge that there are no preferences to save, network connections to close, ...

HTH,
Horst

Or just have one method that is call on exit and know what it should save or/and close, so the OS will not have to call thousand of useless destructors. (like -applicationWillTerminate: in Cocoa).




FWIW, the OS does not call destructors.

A WillTerminate-contract is certainly a good way to avoid calling tons of needless destructors. My point is the nature of contracts: everybody involved (the gadgets and the app) knows the contract and hence does not expect the destructor to be called at exit time. Once the contract is established and all gadgets comply all is well.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Horst Hoesel <email@hidden>)
 >Re: Memory Leak (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: CrashReporter prevents my debugged application from going away
  • Next by Date: Re: CrashReporter prevents my debugged application from going away
  • Previous by thread: Re: Memory Leak
  • Next by thread: Re: Memory Leak
  • Index(es):
    • Date
    • Thread