All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [Patch] avoid memory leak in xend
Date: Mon, 03 Aug 2009 14:04:07 +0200	[thread overview]
Message-ID: <4A76D237.2040300@ts.fujitsu.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

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@ts.fujitsu.com
Otto-Hahn-Ring 6                        Internet: ts.fujitsu.com
D-81739 Muenchen                 Company details: ts.fujitsu.com/imprint.html

[-- Attachment #2: xend-memleak.patch --]
[-- Type: text/x-patch, Size: 1558 bytes --]

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@ts.fujitsu.com


# HG changeset patch
# User juergen.gross@ts.fujitsu.com
# 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()
     

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2009-08-03 12:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A76D237.2040300@ts.fujitsu.com \
    --to=juergen.gross@ts.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.