Skip to content

Conversation

rbagd
Copy link
Contributor

@rbagd rbagd commented Nov 27, 2024

EngineTracer singleton class in SQLAlchemy instrumentations keeps weak references to a traced SQLAlchemy engine forever which can cause a noticeable memory leak if engines are constantly being created.

Description

Previously raised issue #1761 regarding a memory leak in SQLAlchemy instrumentation was partially fixed by yours truly in PR#1771, but the fix appears to have been incomplete. This PR should completely fix #1761.

Fixes #1761

Type of change

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

How Has This Been Tested?

  • Additional unit test to ensure objects are cleaned up

Does This PR Require a Core Repo Change?

  • 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

EngineTracer in SQLAlchemy keeps weak references to a traced engine forever which
can cause a noticeable memory leak if engines are constantly getting creating.
@rbagd rbagd requested a review from a team as a code owner November 27, 2024 23:15
@xrmx xrmx enabled auto-merge (squash) December 3, 2024 09:23
@xrmx xrmx merged commit b6541f0 into open-telemetry:main Dec 3, 2024
573 checks passed
@rbagd rbagd deleted the fix-enginetracer-memoryleak branch December 3, 2024 12:30
xrmx added a commit to xrmx/opentelemetry-python-contrib that referenced this pull request Jan 24, 2025
… singleton (open-telemetry#3053)

* Remove references to SQLAlchemy engines which are disposed of

EngineTracer in SQLAlchemy keeps weak references to a traced engine forever which
can cause a noticeable memory leak if engines are constantly getting creating.

* Updated changelog

---------

Co-authored-by: Emídio Neto <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

sqlalchemy memory leak with Engine cleanup introduced in 0.37b0

5 participants