summaryrefslogtreecommitdiffstats
path: root/tests/old/memleak.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/old/memleak.py')
-rw-r--r--tests/old/memleak.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/old/memleak.py b/tests/old/memleak.py
new file mode 100644
index 0000000..44b123e
--- /dev/null
+++ b/tests/old/memleak.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+
+import gc
+import time
+
+import apt_pkg
+
+import apt
+
+cache = apt.Cache()
+
+# memleak
+for i in range(100):
+ cache.open(None)
+ print(cache["apt"].name)
+ time.sleep(1)
+ gc.collect()
+ f = open("%s" % i, "w")
+ for obj in gc.get_objects():
+ f.write("%s\n" % str(obj))
+ f.close()
+
+# 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.Cache()
+ depcache = apt_pkg.DepCache(cache)
+ records = apt_pkg.PackageRecords(cache)
+ list = apt_pkg.SourceList()
+ list.read_main_list()
+ dict = {}
+ for pkg in cache.packages:
+ if len(pkg.version_list) > 0:
+ dict[pkg.name] = apt.package(cache, depcache, records, list, None, pkg)
+
+ print(cache["apt"])
+ time.sleep(1)
+
+ gc.collect()