|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] python/xc: add missing Py_DECREF() to fix a memory leak
commit d1ef21a5d1222c3b32d3d2314aafc16e948040f6
Author: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
AuthorDate: Fri Aug 28 17:35:18 2015 -0400
Commit: Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Tue Sep 1 12:05:19 2015 +0100
python/xc: add missing Py_DECREF() to fix a memory leak
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 <pid>
Signed-off-by: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
tools/python/xen/lowlevel/xc/xc.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/python/xen/lowlevel/xc/xc.c
b/tools/python/xen/lowlevel/xc/xc.c
index 2c36eb2..9a161d3 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -1210,6 +1210,7 @@ static PyObject *pyxc_getcpuinfo(XcObject *self, PyObject
*args, PyObject *kwds)
for (i = 0; i < nr_cpus; i++) {
cpuinfo_obj = Py_BuildValue("{s:k}", "idletime",
cpuinfo_ptr->idletime);
PyList_Append(cpuinfo_list_obj, cpuinfo_obj);
+ Py_DECREF(cpuinfo_obj);
cpuinfo_ptr++;
}
--
generated by git-patchbot for /home/xen/git/xen.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |