From 5b83af49c192ba902782026573c126fea804c803 Mon Sep 17 00:00:00 2001 From: "tkchin@webrtc.org" Date: Wed, 3 Sep 2014 22:53:34 +0000 Subject: [PATCH] Fix leak of NSAutoreleasePool. This looks like something that's no longer applicable. From what I saw this code path isn't on a static initializer that runs before main. Should be okay to drain (release) pool outside of this scope. BUG=3659 R=henrike@webrtc.org, jiayl@webrtc.org, noahric@chromium.org Review URL: https://webrtc-codereview.appspot.com/13229004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7048 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/base/maccocoathreadhelper.mm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/webrtc/base/maccocoathreadhelper.mm b/webrtc/base/maccocoathreadhelper.mm index 7bf9e9206b..59ae6c4c99 100644 --- a/webrtc/base/maccocoathreadhelper.mm +++ b/webrtc/base/maccocoathreadhelper.mm @@ -23,12 +23,7 @@ void InitCocoaMultiThreading() { if ([NSThread isMultiThreaded] == NO) { // The sole purpose of this autorelease pool is to avoid a console // message on Leopard that tells us we're autoreleasing the thread - // with no autorelease pool in place; we can't set up an autorelease - // pool before this, because this is executed from an initializer, - // which is run before main. This means we leak an autorelease pool, - // and one thread, and if other objects are set up in initializers after - // this they'll be silently added to this pool and never released. - + // with no autorelease pool in place. // Doing NSAutoreleasePool* hack = [[NSAutoreleasePool alloc] init]; // causes unused variable error. NSAutoreleasePool* hack; @@ -36,6 +31,7 @@ void InitCocoaMultiThreading() { [NSThread detachNewThreadSelector:@selector(class) toTarget:[NSObject class] withObject:nil]; + [hack drain]; } assert([NSThread isMultiThreaded]);