Skip to content

Add an "assert mode" to -X showrefcount that fails when references leak #94755

Description

@encukou

The -X showrefcount option currently prints the number of references at exit.
Once we get the number to 0, we should test that it stays that way. It would be nice to add a mode, say -X showrefcount=assert0 or -X checkrefcount, that exits with nonzero if refs/blocks remain. Then it can be used in subprocess tests.

cc @vstinner

Activity

  1. jkloth commented on Jul 11, 2022

    @jkloth
    Contributor

    There is an existing test for 0 leaked refcounts: test_embed.test_no_memleak.

    It currently only ensures that leaks do not occur within just an init/fini cycle.

  2. vstinner commented on Aug 3, 2022

    @vstinner
    Member

    I'm not sure if such feature would be useful today, since there are still many Python stdlib extensions which leak memory at exit :-(

    Well, at least last time I checked. Maybe things went better since I checked.

  3. encukou commented on Aug 4, 2022

    @encukou
    MemberAuthor

    Well, there are some extensions/tests that don't leak memory, and the option could be used to ensure those don't start leaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions