aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMSignalHandler.m
diff options
context:
space:
mode:
Diffstat (limited to 'Foundation/GTMSignalHandler.m')
-rw-r--r--Foundation/GTMSignalHandler.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/Foundation/GTMSignalHandler.m b/Foundation/GTMSignalHandler.m
index 557d8be..b6cfb70 100644
--- a/Foundation/GTMSignalHandler.m
+++ b/Foundation/GTMSignalHandler.m
@@ -105,6 +105,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(gSignalKQueueFileDescriptor, NULL, 0, &event, 1, NULL) == -1) {
@@ -114,6 +120,7 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type,
[handler notify];
}
+ [pool drain];
}
// Cribbed from Advanced Mac OS X Programming