From patchwork Tue Mar 12 12:48:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15287 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EB9DA23E10 for ; Tue, 12 Mar 2013 12:48:28 +0000 (UTC) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by fiordland.canonical.com (Postfix) with ESMTP id A2AB3A180D0 for ; Tue, 12 Mar 2013 12:48:28 +0000 (UTC) Received: by mail-vb0-f47.google.com with SMTP id e21so2187814vbm.20 for ; Tue, 12 Mar 2013 05:48:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=B33gdy/G/myE6weP5vZr1NVQxdf9IthAiF46hWQ+ZaQ=; b=SISvkmASzNUI9ZASoMxQguIi+4pGR0BCeYbnnPQI5d0XkqYPrUCby29ZhhKw9UMOiU 9/1pXjQXmt1rdrv4ctaL00ZGDOjGBPS4gLxDRo0hQK3ImXu588xr1jRmexWLB7rqyUDY 0TpaifUf6vhyq52/Vk+xXRhWdP0KPWOZYHtMLJwc6reWTZHSqamN8GSg8MBpp3nuvz8n LruA5w9/lPE2rA0stkWCWekOGZcSX8GdaAFuaZkR/ahdduwyxxv+uVOQCIJslyEUrfg1 BDsPFcNEgJ4GeXozSB9i+IXOVfaja3ajpbLNseekEyj1zYC4KYBKD0hv/OuavNDPxYBe OCJg== X-Received: by 10.52.18.148 with SMTP id w20mr5666411vdd.8.1363092508152; Tue, 12 Mar 2013 05:48:28 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp126140veb; Tue, 12 Mar 2013 05:48:27 -0700 (PDT) X-Received: by 10.152.104.80 with SMTP id gc16mr13743162lab.49.1363092498813; Tue, 12 Mar 2013 05:48:18 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id sp6si8480229lab.130.2013.03.12.05.48.17 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Mar 2013 05:48:18 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UFOcq-0005Ch-7T; Tue, 12 Mar 2013 12:48:16 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH 1/4] ui/cocoa.m: Fix leaks of NSScreen and NSConcreteMapTable Date: Tue, 12 Mar 2013 12:48:13 +0000 Message-Id: <1363092496-19978-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1363092496-19978-1-git-send-email-peter.maydell@linaro.org> References: <1363092496-19978-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQlJWW9HeLXI6K9Gc2+LC8caJeGld3LsALxCWt14dMpdmRd0DXW57bfNfNOwF/2azOarQVfU On MacOSX 10.8 QEMU provokes system log messages: 11/03/2013 17:03:29.998 qemu-system-arm[42586]: objc[42586]: Object 0x7ffbf9c2f3b0 of class NSScreen autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug 11/03/2013 17:03:29.999 qemu-system-arm[42586]: objc[42586]: Object 0x7ffbf9c3a010 of class NSConcreteMapTable autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug This is because we call back into Cocoa from threads other than the UI thread (specifically from the CPU thread). Since we created these threads via the POSIX API rather than NSThread, they don't have automatically created autorelease pools. Guard all the functions where QEMU can call back into the Cocoa UI code with autorelease pools so that we don't leak any Cocoa objects. Signed-off-by: Peter Maydell --- ui/cocoa.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index ca42413..6e9f751 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -971,6 +971,8 @@ int main (int argc, const char * argv[]) { #pragma mark qemu static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_update\n"); NSRect rect; @@ -984,17 +986,22 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) h * [cocoaView cdy]); } [cocoaView setNeedsDisplayInRect:rect]; + [pool release]; } static void cocoa_resize(DisplayState *ds) { - COCOA_DEBUG("qemu_cocoa: cocoa_resize\n"); + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_resize\n"); [cocoaView resizeContentToWidth:(int)(ds_get_width(ds)) height:(int)(ds_get_height(ds)) displayState:ds]; + [pool release]; } static void cocoa_refresh(DisplayState *ds) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); if (kbd_mouse_is_absolute()) { @@ -1017,11 +1024,15 @@ static void cocoa_refresh(DisplayState *ds) } } while(event != nil); vga_hw_update(); + [pool release]; } static void cocoa_setdata(DisplayState *ds) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + [cocoaView updateDataOffset:ds]; + [pool release]; } static void cocoa_cleanup(void)