[PATCH v2] winemac: Wrap performing requests from background threads in an autorelease pool.

Ken Thomases ken at codeweavers.com
Wed Feb 17 13:14:38 CST 2016


Cocoa manages an autorelease pool on the main thread, but it only drains it
when it processes an event.  Our requests come through a run loop source, which
doesn't count as an event.  So, autoreleased objects can accumulate when the
app is not being interacted with.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
v2: Release the autorelease pool before breaking out of the loop, too.
It wouldn't have been a leak because of the way autorelease pools nest, but this
is better form. Thanks to Andrew Eikum for bring it to my attention.

 dlls/winemac.drv/cocoa_app.m | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index fb9edc2..13b28a6 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -2295,6 +2295,7 @@ static void PerformRequest(void *info)
 
     for (;;)
     {
+        NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
         __block dispatch_block_t block;
 
         dispatch_sync(controller->requestsManipQueue, ^{
@@ -2312,6 +2313,7 @@ static void PerformRequest(void *info)
 
         block();
         [block release];
+        [pool release];
     }
 }
 
-- 
2.6.2




More information about the wine-patches mailing list