diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-01-11 11:54:08 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-01-11 11:54:08 +0000 |
| commit | 372588a9b38e30daa11f499647f0ba822fc2e77f (patch) | |
| tree | 98c0e7cd0032a54a8b30a98a42d03aed224fb83d | |
| parent | ff33c888f56a00e3dea542cfb1091be3585311c8 (diff) | |
| download | python-apt-372588a9b38e30daa11f499647f0ba822fc2e77f.tar.gz | |
* added memleak.py in tests
| -rwxr-xr-x | tests/memleak.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/memleak.py b/tests/memleak.py new file mode 100755 index 00000000..3e59cbb7 --- /dev/null +++ b/tests/memleak.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +import apt +import apt_pkg +import time +import gc +import sys + + +cache = apt.Cache() + +# memleak +#for i in range(100): +# cache.open(None) +# print cache["apt"].name +# time.sleep(1) +# gc.collect() + +# memleak +#for i in range(100): +# cache = apt.Cache() +# time.sleep(1) +# cache = None +# gc.collect() + +# no memleak, but more or less the apt.Cache.open() code +for i in range(100): + cache = apt_pkg.GetCache() + depcache = apt_pkg.GetDepCache(cache) + records = apt_pkg.GetPkgRecords(cache) + list = apt_pkg.GetPkgSourceList() + list.ReadMainList() + dict = {} + for pkg in cache.Packages: + if len(pkg.VersionList) > 0: + dict[pkg.Name] = apt.Package(cache,depcache, + records, list, None, pkg) + + print cache["apt"] + time.sleep(1) + + gc.collect() |
