Re: NSDistributedNotificationCenter questions.
Re: NSDistributedNotificationCenter questions.
- Subject: Re: NSDistributedNotificationCenter questions.
- From: Fritz Anderson <email@hidden>
- Date: Fri, 18 Feb 2011 16:01:42 -0600
On 18 Feb 2011, at 3:00 PM, Mr. Gecko wrote:
> I noticed that memory is not autoreleased when I receive a distributed notification, the only way to fix this is to wrap it in a autorelease pool, but this shouldn't be right? I would think that when you register for a notification it'll be on the run loop which has a autorelease pool and therefore shouldn't leak, instruments doesn't see these allocations as a leak, but you can see they are still alive. The only thing I can think of is that the application who sent it has no autorelease pool and the notification would be like running from a NSConnection (Haven't tested this). So my question is how does the distributed notifications work? Do all of them need to be wrapped in NSAutoreleasePool to prevent leaks? And if not, is that because some applications post the notifications without the autorelease pool (Trying to wrap my head around why this is happening).
You're thrashing around for an explanation for something that I don't think needs explaining.
How do you know "memory is not autoreleased?" What do you mean by that? If it's simply that the retain count isn't what you expect, forget it. Forget retainCount is in the API; if your situation tempts you to look at retainCount, retainCount is almost guaranteed to be misleading. The OS has the right to retain, and later release, any object at any time. So long as you and the OS both obey the memory-management rules (which means, on your part, not sprinkling releases and drains whenever you're in doubt), the object will be deallocated when you and the OS are both done with it.
That Instruments doesn't show "these allocations" (what allocations?) as a leak raises a strong presumption that it isn't a leak. Your attempt to plug a leak that isn't there will crash your application.
You application, the other application, and the OS all have their separate memory spaces and heaps. You (and therefore the retain/release logic for your application) have no access to any heap but your own. It doesn't matter whether the other application has retained its copy (note: copy) of its object. You're looking at your own copy.
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden