diff options
author | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-01-22 21:37:19 +0000 |
---|---|---|
committer | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-01-22 21:37:19 +0000 |
commit | ba7d45cf8c3b1938a51a9b3580919c61bf750f9d (patch) | |
tree | cf058378356511d3615e921e35b481c72019f902 | |
parent | 4fd103b5de98d2f469b982677ea389e7ee7d64b3 (diff) |
Fixing a like Avi found w/ our use of CFRunLoop from some kqueue code.
-rw-r--r-- | Foundation/GTMFileSystemKQueue.m | 7 | ||||
-rw-r--r-- | Foundation/GTMSignalHandler.m | 7 | ||||
-rw-r--r-- | GTM.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | ReleaseNotes.txt | 6 |
4 files changed, 24 insertions, 2 deletions
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 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 diff --git a/GTM.xcodeproj/project.pbxproj b/GTM.xcodeproj/project.pbxproj index dff1850..31d02c5 100644 --- a/GTM.xcodeproj/project.pbxproj +++ b/GTM.xcodeproj/project.pbxproj @@ -257,6 +257,8 @@ F98680C40E2C164300CEE8BF /* GTMLoggerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F98680B10E2C15C300CEE8BF /* GTMLoggerTest.m */; }; F98681960E2C20C100CEE8BF /* GTMLogger+ASLTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F98681950E2C20C100CEE8BF /* GTMLogger+ASLTest.m */; }; F98681970E2C20C800CEE8BF /* GTMLogger+ASL.m in Sources */ = {isa = PBXBuildFile; fileRef = F98681680E2C1E3A00CEE8BF /* GTMLogger+ASL.m */; }; + F99161B50F0B151400213D3B /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F99161B40F0B151400213D3B /* libsqlite3.dylib */; }; + F99163270F14100F00213D3B /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F99161B40F0B151400213D3B /* libsqlite3.dylib */; }; F9FD94630E1D31280005867E /* GTMPath.m in Sources */ = {isa = PBXBuildFile; fileRef = F9FD945C0E1D30F80005867E /* GTMPath.m */; }; F9FD94640E1D312E0005867E /* GTMPathTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F9FD945D0E1D30F80005867E /* GTMPathTest.m */; }; F9FD94CD0E1D50450005867E /* GTMPath.h in Headers */ = {isa = PBXBuildFile; fileRef = F9FD945E0E1D30F80005867E /* GTMPath.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -553,6 +555,7 @@ F98681670E2C1E3A00CEE8BF /* GTMLogger+ASL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMLogger+ASL.h"; sourceTree = "<group>"; }; F98681680E2C1E3A00CEE8BF /* GTMLogger+ASL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMLogger+ASL.m"; sourceTree = "<group>"; }; F98681950E2C20C100CEE8BF /* GTMLogger+ASLTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMLogger+ASLTest.m"; sourceTree = "<group>"; }; + F99161B40F0B151400213D3B /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = /usr/lib/libsqlite3.dylib; sourceTree = "<absolute>"; }; F9FD945C0E1D30F80005867E /* GTMPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMPath.m; sourceTree = "<group>"; }; F9FD945D0E1D30F80005867E /* GTMPathTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMPathTest.m; sourceTree = "<group>"; }; F9FD945E0E1D30F80005867E /* GTMPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMPath.h; sourceTree = "<group>"; }; @@ -588,6 +591,7 @@ F42E08800D199AB500D5DDE0 /* GoogleToolboxForMac.framework in Frameworks */, F42E089D0D199B1800D5DDE0 /* SenTestingKit.framework in Frameworks */, 8BC046B90DAE8C4B00C2D1CA /* ApplicationServices.framework in Frameworks */, + F99161B50F0B151400213D3B /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -595,6 +599,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F99163270F14100F00213D3B /* libsqlite3.dylib in Frameworks */, F42E095E0D199BD600D5DDE0 /* Cocoa.framework in Frameworks */, F42E09AE0D19A62F00D5DDE0 /* Carbon.framework in Frameworks */, F43E4F6D0D4E60C50041161F /* libz.dylib in Frameworks */, @@ -653,6 +658,7 @@ 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = { isa = PBXGroup; children = ( + F99161B40F0B151400213D3B /* libsqlite3.dylib */, 8B45A1990DA46AAA001148C5 /* QuartzCore.framework */, F43E4F6C0D4E60C50041161F /* libz.dylib */, 0867D6A5FE840307C02AAC07 /* AppKit.framework */, diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index b592a31..993c885 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -12,7 +12,8 @@ Changes since 1.5.1 - Added GTMSignalHandler for simple signal handling (via kqueue/runloop). This has gotten an api tweak, so some code that started using it will need - updating. + updating. Initial landing had a bug where it could leak memory due to + how CFRunLoops work, now fixed. - Fixed up GTMIPhoneUnitTestDelegate to be pickier about which tests it runs @@ -193,7 +194,8 @@ Changes since 1.5.1 issues that were interfering with unittests. - Added GTMFileSystemKQueue. It provides a simple wrapper for kqueuing - something in the file system and tracking changes to it. + something in the file system and tracking changes to it. Initial landing + had a bug where it could leak memory due to how CFRunLoops work, now fixed. - RunIPhoneUnitTest.sh now cleans up the user home directory and creates a documents directory within it, used when requesting a NSDocumentDirectory. |