[PATCH v3] winemac: Wrap performing requests from background threads in an autorelease pool.
Ken Thomases
ken at codeweavers.com
Wed Feb 17 13:42:54 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>
---
v3: Actually include the code change I intended for v2. Thanks again to Andrew Eikum.
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 | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index fb9edc2..176d35c 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, ^{
@@ -2308,10 +2309,14 @@ static void PerformRequest(void *info)
});
if (!block)
+ {
+ [pool release];
break;
+ }
block();
[block release];
+ [pool release];
}
}
--
2.6.2
More information about the wine-patches
mailing list