Maybe I am missing something, but given your example - which in some sense 
contradicts your comment, why do you expect dealloc to be called?

If the retain count is in fact > 0 after the release (4 in your example below) 
dealloc is not called, since the view can not yet be deallocated.
View.release just means "*I* (i.e. the caller) don't care about you any 
longer". But if some other object still cares (i.e. the retain count > 0, as in 
your example), dealloc won't be called. In short: release != dealloc. Or the 
other way round: only after x retains are balanced by the same number of 
release messages, dealloc eventually will be called by the runtime and the 
object is  finally cleaned up and purged from memory.

Sorry if I am getting you wrong and point out the obvious ...

Am 17.07.2011 um 22:41 schrieb Ryan Joseph:

> Simple question that is causing serious memory leaks in my app. Why given 
> that example will dealloc never be called? I know the retainCount doesn't 
> tell the whole story and it may be retained by other objects (rightfully so) 
> but then WHEN will it be released if not when I request it to? I must be 
> missing something... Thanks!
> 
> The code (in Pascal):
> 
> view := NSTextView.alloc.initWithFrame(NSMakeRect(0, 0, 0, 0));
> // retainCount = 5
> view.release;
> // retainCount = 4, dealloc never called
> 
> Regards,
>       Ryan Joseph
>       thealchemistguild.com

_______________________________________________

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 arch...@mail-archive.com

Reply via email to