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

Fix memory leak caused by fixture values never been garbage collected #3030

Merged
merged 1 commit into from
Dec 14, 2017

Conversation

nicoddemus
Copy link
Member

The leak was caused by the (unused) FixtureRequest._fixture_values
cache.

This was introduced because the partial object (created to call
FixtureDef.finish() bound with the Request) is kept alive
through the entire session when a function-scoped fixture depends
on a session-scoped (or higher) fixture because of the nested
addfinalizer calls.

FixtureDef.finish() started receiving a request object in order to
obtain the proper hook proxy object (#2127), but this does not seem
useful at all in practice because pytest_fixture_post_finalizer
will be called with the request object of the moment the fixture value
was created, not the request object active when the fixture value
is being destroyed. We should probably deprecate/remove the request
parameter from pytest_fixture_post_finalizer.

Fix #2981

The leak was caused by the (unused) `FixtureRequest._fixture_values`
cache.

This was introduced because the `partial` object (created to call
FixtureDef.finish() bound with the Request) is kept alive
through the entire session when a function-scoped fixture depends
on a session-scoped (or higher) fixture because of the nested
`addfinalizer` calls.

FixtureDef.finish() started receiving a request object in order to
obtain the proper hook proxy object (pytest-dev#2127), but this does not seem
useful at all in practice because `pytest_fixture_post_finalizer`
will be called with the `request` object of the moment the fixture value
was *created*, not the request object active when the fixture value
is being destroyed. We should probably deprecate/remove the request
parameter from `pytest_fixture_post_finalizer`.

Fix pytest-dev#2981
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 92.585% when pulling c3f63ac on nicoddemus:leak into 476d4df on pytest-dev:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Session fixture keeps frames of other fixtures alive
3 participants