From ba7d45cf8c3b1938a51a9b3580919c61bf750f9d Mon Sep 17 00:00:00 2001 From: "thomasvl@gmail.com" Date: Thu, 22 Jan 2009 21:37:19 +0000 Subject: Fixing a like Avi found w/ our use of CFRunLoop from some kqueue code. --- Foundation/GTMFileSystemKQueue.m | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Foundation/GTMFileSystemKQueue.m') diff --git a/Foundation/GTMFileSystemKQueue.m b/Foundation/GTMFileSystemKQueue.m index ebb2ec8..ad516f7 100644 --- a/Foundation/GTMFileSystemKQueue.m +++ b/Foundation/GTMFileSystemKQueue.m @@ -107,6 +107,12 @@ static CFSocketRef gRunLoopSocket = NULL; // Cribbed from Advanced Mac OS X Programming. static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) { + // We're using CFRunLoop calls here. Even when used on the main thread, they + // don't trigger the draining of the main application's autorelease pool that + // NSRunLoop provides. If we're used in a UI-less app, this means that + // autoreleased objects would never go away, so we provide our own pool here. + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + struct kevent event; if (kevent(gFileSystemKQueueFileDescriptor, NULL, 0, &event, 1, NULL) == -1) { @@ -116,6 +122,7 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type, [fskq notify:event.fflags]; } + [pool drain]; } // Cribbed from Advanced Mac OS X Programming -- cgit v1.2.3