source: yum/trunk/test/yum-leak-test.py@ 6

Last change on this file since 6 was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 1015 bytes
Line 
1#! /usr/bin/python -tt
2
3import yum, os, time, gc
4from urlgrabber.progress import format_number
5
6def out_mem(pid):
7 ps = {}
8 for line in open("/proc/%d/status" % pid):
9 if line[-1] != '\n':
10 continue
11 data = line[:-1].split(':\t', 1)
12 if data[1].endswith(' kB'):
13 data[1] = data[1][:-3]
14 ps[data[0].strip().lower()] = data[1].strip()
15 if 'vmrss' in ps and 'vmsize' in ps:
16 print "* Memory : %5s RSS (%5sB VSZ)" % \
17 (format_number(int(ps['vmrss']) * 1024),
18 format_number(int(ps['vmsize']) * 1024))
19
20out_mem(os.getpid())
21while True:
22 yb = yum.YumBase()
23 yb.repos.setCacheDir(yum.misc.getCacheDir())
24 yb.rpmdb.returnPackages()
25 yb.pkgSack.returnPackages()
26 out_mem(os.getpid())
27 time.sleep(4)
28
29 if False:
30 del yb
31 print len(gc.garbage)
32 if gc.garbage:
33 print gc.garbage[0]
34 print gc.get_referrers(gc.garbage[0])
35 # print "DBG:", gc.get_referrers(yb)
Note: See TracBrowser for help on using the repository browser.