File: memory_leak_test.py

package info (click to toggle)
python-isal 1.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,796 kB
  • sloc: python: 3,190; ansic: 2,952; makefile: 17
file content (19 lines) | stat: -rw-r--r-- 587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gc
import resource
import sys

from isal import igzip

for _ in range(10):
    with igzip.open(sys.argv[1], "rb") as reader:
        a = reader.read()
        print(len(a))
        gc.collect()
        memory_usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
        memory_usage_mb = memory_usage / 1024
        print(f"Maximum memory usage: {memory_usage_mb:.2f} MiB")
        del a
objects_and_size = [(sys.getsizeof(obj), type(obj)) for obj in
                    gc.get_objects()]
objects_and_size.sort(key=lambda x: x[0], reverse=True)
print(objects_and_size[:10])