Skip to content

leak report #13

Answered by wjakob
tbrekalo asked this question in Q&A
Mar 31, 2022 · 2 comments · 11 replies
Discussion options

You must be logged in to vote

For anyone running into this in the future: the problem arises due to a reference leak in typing (not exactly this issue, but this is what pointed me into the right direction: https://bugs.python.org/issue28649).

To avoid this issue, a set of LRU caches related to type information must be cleared before interpreter shutdown, which can be accomplished by running the following anywhere (just once is enough).

# Uncomment to stop leak warnings
import atexit

def cleanup():
    import typing
    for cleanup in typing._cleanups:
        cleanup()

atexit.register(cleanup)

In any case, this is not a nanobind issue. It's just that nanobind complains very loudly about leaks (a good thing!) which …

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
11 replies
@tbrekalo
Comment options

@jbms
Comment options

@tbrekalo
Comment options

@wjakob
Comment options

@tbrekalo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by wjakob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants