Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
encukou opened this issue Jul 11, 2022 · 3 comments
Open
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@encukou
Copy link
Member

encukou commented Jul 11, 2022

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

@jkloth
Copy link
Contributor

jkloth commented Jul 11, 2022

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.

@vstinner
Copy link
Member

vstinner commented Aug 3, 2022

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.

@encukou
Copy link
Member Author

encukou commented Aug 4, 2022

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

@iritkatriel iritkatriel added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants