From patchwork Mon Apr 22 20:29:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 16326 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 960AE23919 for ; Mon, 22 Apr 2013 20:30:46 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id v20sf10636586qcm.9 for ; Mon, 22 Apr 2013 13:29:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=NlN828+BdlEmq7mjgswfwfVDtKGcDLVNLwM7kCBotAg=; b=PvVn3BIi7Re3jcfN2vVLGa85AGtxT4Y8beo+ryURE6t65H4LUEPd1JlJTfbJIZUkXx E8ltKAu/otUuM6/4zoznQJenpuEF9hyyGrDTeeuMAFAOyWI+ul8vzGuyPIulDiNQ6guq bS0R+Mb/OEVfDc+9X7aPrdIK5my7ZJhC5bI/+HA1kDJpAXRKfCuvfW3jezLQFIbYbni4 QfYxvci9EVe6R9mBMpiJLu/OCXaCpWIRMuU73yWKAf/X2QrhzyzGjor9/aMA4puFdC4j ctOlSVlhQAl/nCNgCqEJH2LRmozHOPnAuq4aJypFZJINm0a2TId8xB/eEw0A9iw4oH1+ VZfg== X-Received: by 10.224.10.6 with SMTP id n6mr17074732qan.4.1366662599389; Mon, 22 Apr 2013 13:29:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.107.201 with SMTP id he9ls20124qeb.2.gmail; Mon, 22 Apr 2013 13:29:59 -0700 (PDT) X-Received: by 10.58.80.4 with SMTP id n4mr20059548vex.5.1366662599199; Mon, 22 Apr 2013 13:29:59 -0700 (PDT) Received: from mail-ve0-x230.google.com (mail-ve0-x230.google.com [2607:f8b0:400c:c01::230]) by mx.google.com with ESMTPS id gr7si1115531vdc.142.2013.04.22.13.29.59 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Apr 2013 13:29:59 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::230; Received: by mail-ve0-f176.google.com with SMTP id cz11so746915veb.21 for ; Mon, 22 Apr 2013 13:29:59 -0700 (PDT) X-Received: by 10.221.0.199 with SMTP id nn7mr20497697vcb.14.1366662599073; Mon, 22 Apr 2013 13:29:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp93403veb; Mon, 22 Apr 2013 13:29:55 -0700 (PDT) X-Received: by 10.180.13.179 with SMTP id i19mr12025560wic.18.1366662594501; Mon, 22 Apr 2013 13:29:54 -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 d7si41750420eep.128.2013.04.22.13.29.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 22 Apr 2013 13:29:54 -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; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UUNMz-0004ls-6T; Mon, 22 Apr 2013 21:29:49 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori Subject: [PATCH v3 1/4] ui/cocoa.m: Fix leaks of NSScreen and NSConcreteMapTable Date: Mon, 22 Apr 2013 21:29:46 +0100 Message-Id: <1366662589-18315-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1366662589-18315-1-git-send-email-peter.maydell@linaro.org> References: <1366662589-18315-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQl9QoXDaZ+ccwECZQTI1+GhqiSPSJVBGlt3r4rfdl+U4XKB9k0GWiY5vv8i2ufLpREYVY/H X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index d51462a..833c6ed 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -960,6 +960,8 @@ int main (int argc, const char * argv[]) { static void cocoa_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_update\n"); NSRect rect; @@ -973,18 +975,24 @@ static void cocoa_update(DisplayChangeListener *dcl, h * [cocoaView cdy]); } [cocoaView setNeedsDisplayInRect:rect]; + + [pool release]; } static void cocoa_switch(DisplayChangeListener *dcl, DisplaySurface *surface) { - COCOA_DEBUG("qemu_cocoa: cocoa_resize\n"); + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_switch\n"); [cocoaView switchSurface:surface]; + [pool release]; } static void cocoa_refresh(DisplayChangeListener *dcl) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); if (kbd_mouse_is_absolute()) { @@ -1007,6 +1015,7 @@ static void cocoa_refresh(DisplayChangeListener *dcl) } } while(event != nil); graphic_hw_update(NULL); + [pool release]; } static void cocoa_cleanup(void)