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

Use a weak reference to sqlalchemy Engine to avoid memory leak #1

Closed
wants to merge 4 commits into from

Conversation

rbagd
Copy link
Owner

@rbagd rbagd commented Apr 20, 2023

Description

By using a weak reference to the Engine object, we can avoid the memory leak as disposed Engines get properly deallocated. Whenever SQLAlchemy is uninstrumented, we only trigger a removal of those event listeners which are listening for objects that haven't been garbage-collected yet.

Fixes open-telemetry#1761

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • TBD

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

rbagd and others added 4 commits April 21, 2023 00:32
Closes open-telemetry#1761

By using a weak reference to the `Engine` object, we can avoid the memory leak as disposed `Engines` get properly deallocated. Whenever `SQLAlchemy` is uninstrumented, we only trigger a removal for those event listeners which are listening for objects that haven't been garbage-collected yet.
@rbagd rbagd closed this Apr 22, 2023
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.

sqlalchemy memory leak with Engine cleanup introduced in 0.37b0
1 participant