WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [Patch] avoid memory leak in xend

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [Patch] avoid memory leak in xend
From: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
Date: Mon, 03 Aug 2009 14:04:07 +0200
Delivery-date: Mon, 03 Aug 2009 05:05:58 -0700
Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=ts.fujitsu.com; i=juergen.gross@xxxxxxxxxxxxxx; q=dns/txt; s=s1536b; t=1249300976; x=1280836976; h=from:sender:reply-to:subject:date:message-id:to:cc: mime-version:content-transfer-encoding:content-id: content-description:resent-date:resent-from:resent-sender: resent-to:resent-cc:resent-message-id:in-reply-to: references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:list-owner:list-archive; z=From:=20Juergen=20Gross=20<juergen.gross@xxxxxxxxxxxxxx> |Subject:=20[Patch]=20avoid=20memory=20leak=20in=20xend |Date:=20Mon,=2003=20Aug=202009=2014:04:07=20+0200 |Message-ID:=20<4A76D237.2040300@xxxxxxxxxxxxxx>|To:=20"x en-devel@xxxxxxxxxxxxxxxxxxx"=20<xen-devel@xxxxxxxxxxxxxx e.com>|MIME-Version:=201.0; bh=zbu/C/Pbv9j60Kyrk43caSYPnWZU778JtrSbCU0UJYU=; b=mT1UFtXiS1holyc8SgJsr9ynKyPbvVfcUTA/apXBvlO4hoDxnByW+g9r LYs4ExGc18MfaclyY9lRqCpaeaRl2v8eql9idT9hz0wuqX8AzxBgvH8L4 XTJYazJzwlhFOs6q0B7ParUm/cqvNOas1ntAufHkLBg0QnRatF8R4X6WO uA//iSRX96wDu1YgG6wTY45xuzDjnY46wl3vmRU68fzmi9Sb8jfxGOdP8 GsuVzbNbQrRYi4PevUR4ls7sV4R4F;
Domainkey-signature: s=s1536a; d=ts.fujitsu.com; c=nofws; q=dns; h=X-SBRSScore:X-IronPort-AV:Received:X-IronPort-AV: Received:Received:Message-ID:Date:From:Organization: User-Agent:MIME-Version:To:Subject:X-Enigmail-Version: Content-Type; b=NJ6JDOtBx6Ol+HbTafgUv15lwMwUQNxos8ock/Mvsp8GqDm+EQloj3mv Q+yjGO34jOOz4skXtMPXeSIrRbWy0N4n6AmJkxhbJtFBNRF2i1eOTXkGY 07FCd4ZEiAyTO3/Xc7MMDEuK6Lqx89xJOa9etShZS2OgQNunDzis/6cPB J56dEDMjhmawAT7Km74taIGsgl4Ah3sMysiJzjewzTERxPlpLQWZwavwW YnsbDrdBMHHl+4gLuFY4w8s3AZeV7;
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Fujitsu Technology Solutions
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707)
Hi,

Attached patch removes a memory leak in xend.


Juergen

-- 
Juergen Gross                 Principal Developer Operating Systems
TSP ES&S SWE OS6                       Telephone: +49 (0) 89 636 47950
Fujitsu Technolgy Solutions               e-mail: juergen.gross@xxxxxxxxxxxxxx
Otto-Hahn-Ring 6                        Internet: ts.fujitsu.com
D-81739 Muenchen                 Company details: ts.fujitsu.com/imprint.html
Memory leak in Xend, resulting in long garbage collector runs.

In the method xen.xend.XendStateStore.XendStateStore.load_state and
xen.xend.XendStateStore.XendStateStore.save_state the minidom objects used to
load/save the current state of a device type, can't be freed by the python
garbage collector after all references to the top node are cleared, because of
cyclic references between the DOM nodes. So memory usage of xend increases
after calling these methods.
To solve this problem, the unlink() method must be called for a minidom object
before the last reference to the top node is cleared (see python docs). This
breaks the cyclic references, so the garbage collector can free these objects.

Signed-off-by: juergen.gross@xxxxxxxxxxxxxx


# HG changeset patch
# User juergen.gross@xxxxxxxxxxxxxx
# Date 1249300432 -7200
# Node ID d40abdac1cf42ae552f727750cd0cca0b8d32361
# Parent  41b2c4e4f6746c638192b88ea37d3d25196850ad
Avoid memory leak in xend

diff -r 41b2c4e4f674 -r d40abdac1cf4 tools/python/xen/xend/XendStateStore.py
--- a/tools/python/xen/xend/XendStateStore.py   Wed Jul 29 09:20:46 2009 +0100
+++ b/tools/python/xen/xend/XendStateStore.py   Mon Aug 03 13:53:52 2009 +0200
@@ -147,6 +147,7 @@
                     cls_dict[val_name] = bool(int(val_text))
             state[uuid] = cls_dict
 
+        dom.unlink()
         return state
 
     def save_state(self, cls, state):
@@ -226,5 +227,5 @@
                     node.appendChild(val_node)
 
         open(xml_path, 'w').write(doc.toprettyxml())
-        
+        doc.unlink()
     
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [Patch] avoid memory leak in xend, Juergen Gross <=