From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] python/xc: add missing Py_DECREF() to fix a memory leak Date: Tue, 1 Sep 2015 12:07:28 +0100 Message-ID: <1441105648.27618.40.camel@citrix.com> References: <1440797718-28045-1-git-send-email-zhigang.x.wang@oracle.com> <20150831120456.GA22586@zion.uk.xensource.com> <55E44837.5000902@citrix.com> <20150831123208.GA7274@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZWjPY-0008EF-Ds for xen-devel@lists.xenproject.org; Tue, 01 Sep 2015 11:07:32 +0000 In-Reply-To: <20150831123208.GA7274@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu , Andrew Cooper Cc: xen-devel@lists.xenproject.org, Zhigang Wang List-Id: xen-devel@lists.xenproject.org On Mon, 2015-08-31 at 13:32 +0100, Wei Liu wrote: > On Mon, Aug 31, 2015 at 01:27:35PM +0100, Andrew Cooper wrote: > > On 31/08/2015 13:04, Wei Liu wrote: > > > On Fri, Aug 28, 2015 at 05:35:18PM -0400, Zhigang Wang wrote: > > > > Python PyList_Append() will increase reference count of the item. > > > > We have to > > > > decrease its reference count to let it garbage collected. > > > > > > > > We missed the Py_DECREF() for 'cpuinfo_obj' here, thus we have a > > > > memory leak. > > > > > > > > The memory leak could be easily confirmed by: > > > > > > > > # python > > > > >>> import xen.lowlevel.xc > > > > >>> xc = xen.lowlevel.xc.xc() > > > > >>> for i in range(1000): xc.getcpuinfo(1) > > > > > > > > And check the python process memory usage before and after: > > > > > > > > # ps f -o vsize,rss,%mem,size,cmd -p > > > > > > > > Signed-off-by: Zhigang Wang > > > Acked-by: Wei Liu > > > > > > There is no in-tree user of python binding, I was planning to remove > > > it > > > in 4.7 window. > > > > I am sure I have mentioned this in the past, but XenServer still uses > > them in places, and they are very useful to use from interactive > > sessions. > > > > That's why I said "was". :-) > > I don't mind leaving it in-tree given there is out-of-tree users. The > problem is I don't think I can do a good job maintaining this piece of > code that I don't use and can't test, hence I encourage users to step > forward to maintain this piece of code. I too would be happy to see a patch to MAINTAINERS adding a section covering at least tools/python/xen/lowlevel/xc (maybe xs too) and some names of some actual users/maintainers of that code. I think the xl bindings are properly dead and should be removed. Ian.