• 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: CFRunLoopObserver causes crash on NSView drag.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFRunLoopObserver causes crash on NSView drag.


  • Subject: Re: CFRunLoopObserver causes crash on NSView drag.
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 22 Oct 2011 09:48:40 -0500

On Oct 22, 2011, at 8:53 AM, Mr. Gecko wrote:

> static NSAutoreleasePool *pool = nil;
>
> void runloop(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) {
> 	if (activity & kCFRunLoopEntry) {
> 		if (pool!=nil) [pool drain];
> 		pool = [NSAutoreleasePool new];
> 	} else if (activity & kCFRunLoopExit) {
> 		[pool drain];
> 		pool = nil;
> 	}
> }

I very much doubt this is kosher.  An autorelease pool exists in a stack.  If the outer autorelease pool is popped, then yours is deallocated whether or not you've released or drained it.  After that happens, you have a dangling pointer.  It really makes no sense to have an autorelease pool with a lifetime greater than the scope of its usage.

Have you tried running a timer to see if that provokes draining of the autorelease pool managed by the framework?  Have you tried posting a custom event?

Even if those fail, the best approach is to just use local autorelease pools in whatever methods you introduce which are creating temporary objects that would otherwise live longer than you'd like.

Regards,
Ken

_______________________________________________

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

References: 
 >CFRunLoopObserver causes crash on NSView drag. (From: "Mr. Gecko" <email@hidden>)

  • Prev by Date: CFRunLoopObserver causes crash on NSView drag.
  • Next by Date: Re: Scripting Bridge warning: 'no class for scripting class "iTunesBrowserWindow"'
  • Previous by thread: CFRunLoopObserver causes crash on NSView drag.
  • Next by thread: Re: CFRunLoopObserver causes crash on NSView drag.
  • Index(es):
    • Date
    • Thread