PetterS / quickjs

Thin Python wrapper of https://bellard.org/quickjs/
https://github.com/bellard/QuickJS
MIT License
177 stars 19 forks source link

More specific memory checks #75

Closed qwenger closed 2 years ago

qwenger commented 2 years ago

Currently, when testing check_memory.py, most tracebacks come from standard packages, thus are not useful (if I understand tracemalloc correctly).

I suggest to filter for tracebacks originating only from quickjs/__init__.py or test_quickjs.py.

Note: we could also filter out the different unwanted packages, but then we'd end up with something like that (plus all the corresponding imports):

filters = [
    tracemalloc.Filter(False, tracemalloc.__file__),
    tracemalloc.Filter(False, threading.__file__),
    tracemalloc.Filter(False, re.__file__),
    tracemalloc.Filter(False, re.sre_compile.__file__),
    tracemalloc.Filter(False, re.sre_parse.__file__),
    tracemalloc.Filter(False, weakref.__file__),
    tracemalloc.Filter(False, _weakrefset.__file__),
    tracemalloc.Filter(False, unittest.suite.__file__),
    tracemalloc.Filter(False, unittest.case.__file__),
    tracemalloc.Filter(False, unittest.loader.__file__),
    tracemalloc.Filter(False, unittest.runner.__file__),
    tracemalloc.Filter(False, unittest.result.__file__),
    tracemalloc.Filter(False, fnmatch.__file__),
    tracemalloc.Filter(False, concurrent.futures.thread.__file__),
    tracemalloc.Filter(False, concurrent.futures._base.__file__),
    tracemalloc.Filter(False, abc.__file__),
    tracemalloc.Filter(False, traceback.__file__),
    tracemalloc.Filter(False, posixpath.__file__),
    tracemalloc.Filter(False, json.encoder.__file__),
    tracemalloc.Filter(False, __file__),
    tracemalloc.Filter(False, "<unknown>"),
]

Note2: even after filtering, tracebacks remain... does that mean that we do have memory leaks in module.c?

PetterS commented 2 years ago

Note2: even after filtering, tracebacks remain... does that mean that we do have memory leaks in module.c?

We'll have to look into that, but yes, that should be a memory leak.