[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Various retain/release bugs

From: Nicola Pero
Subject: Re: Various retain/release bugs
Date: Fri, 22 Feb 2002 18:34:14 +0000 (GMT)

> 1.
> In [NSApplication -terminate:] the application tries to dealloc itself,
> but it's still being retained by the
> NSApplicationWillTerminateNotification. I talked about it with
> Pierre-Yves (IRC) and he suggested that exit() should be called in
> NSApplicationMain() instead of in terminate:. I moved the DESTROY(NSApp)
> and exit() to NSApplicationMain() (sortof), and it seemed to work (and
> it took care of ~1000 unreleased objects).

Hmmm ... I added an autorelease pool to NSApplication.m -terminate:, which
at least causes the NSApp to dealloc.

But I suppose this won't dealloc all the objects it should ... the actual
complete fix might be to store the current application runloop autorelease
pool (the one setup inside -run) into an ivar, so that -terminate: can
destroy that autorelease pool.

Anyone with comments against that change ?


In general all this work of destroying all objects ordinately by hand, one
by one, on shutdown will actually cause the shutdown to be slower -
calling exit(0) without deallocating anything and just returning all the
process memory to the environment immediately is much faster.

But of course the point is that you might have created an object which is
taking up some files/network resources/distributed locks, and you releases
these resources in the -dealloc method of the object.  We need then to
dealloc all objects ordinately so that the -dealloc of your object is
actually called and the resources are actually freed.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]