Re: Delayed termination to allow release
On Aug 11, 2008, at 11:33 AM, Trygve Inda wrote: My main thread creates a few other objects which have NSThreads and/or timers. I have found that when I quit the app, and the threads are ended, something in the OS is retaining my objects for a bit... They end up never being dealloc'd which messes a few things up as some data is written to disk at this point. -dealloc is short circuited when an application is quit (as deallocation is going to occur due to the application's memory space going away). You should arrange for things that need to occur on application quit to occur in -applicationShouldTerminate: without relying on object lifetimes to do this (if you ever write a GC enabled application you will find you have the same issues in that you cannot message an object in -finalize reliably). -- David Duncan Apple DTS Animation and Printing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Delayed termination to allow release
Am Mo,11.08.2008 um 20:33 schrieb Trygve Inda: My main thread creates a few other objects which have NSThreads and/or timers. I have found that when I quit the app, and the threads are ended, something in the OS is retaining my objects for a bit... They end up never being dealloc'd which messes a few things up as some data is written to disk at this point. […] What you are doing is finalization. In most cases this is simply a wrong design. -dealloc is for 1. memory management 2. memory management 3. memory management It is not for additional functionality bound to an instance. (I do know what I talk about, because I did this mistake many times.) If you find no other solution just register your threads (whatever) in the app-delegate and clean it up at -applicationDidFinishLaunching.. Amin Negm-Awad [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Delayed termination to allow release
Trygve Inda wrote: My main thread creates a few other objects which have NSThreads and/or timers. I have found that when I quit the app, and the threads are ended, something in the OS is retaining my objects for a bit... They end up never being dealloc'd which messes a few things up as some data is written to disk at this point. ... In my obj alloc I set objCount++ and in the dealloc I set objCount-- Is there a better way around this? Without delaying the termination for the OS to clean up (guessing some autorelease pool), some of my objects are never dealloc'd and the app simply goes away with no error. Thoughts? My primary thought is that dealloc is not the place to perform required termination-time tasks, because there's no guarantee it'll be called. Deallocation is where you let go of subsidiary allocations. If you've got objects that need to do things at termination, register them as observers of NSApplicationWillTerminateNotification. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Delayed termination to allow release
Am Mo,11.08.2008 um 20:57 schrieb Negm-Awad Amin: Am Mo,11.08.2008 um 20:33 schrieb Trygve Inda: My main thread creates a few other objects which have NSThreads and/ or timers. I have found that when I quit the app, and the threads are ended, something in the OS is retaining my objects for a bit... They end up never being dealloc'd which messes a few things up as some data is written to disk at this point. […] What you are doing is finalization. In most cases this is simply a wrong design. -dealloc is for 1. memory management 2. memory management 3. memory management It is not for additional functionality bound to an instance. (I do know what I talk about, because I did this mistake many times.) If you find no other solution just register your threads (whatever) in the app-delegate and clean it up at - applicationDidFinishLaunching.. Args##%+*$%!/ Of course, -applicationWillTerminate: as somebody said. Amin Negm-Awad [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]