Fix memory leak in exporter and reader by msoltysik · Pull Request #4224 · open-telemetry/opentelemetry-python
Description
This PR addresses memory leak issue in the exporter and reader by using the weakref library.
The solution, proposed by @aabmass, utilizes weakref.WeakMethod and weakref.WeakSet to ensure proper garbage collection and prevent unintended object retention.
Discussion can be found in the following issue - Fixes #4220
Type of change
- Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
It has been covered by a test case.
============================= test session starts ==============================
collecting ... collected 1 item
test_provider_shutdown.py::TestMeterProviderShutdown::test_meter_provider_shutdown_cleans_up_successfully PASSED [100%]
============================== 1 passed in 0.08s ===============================
Does This PR Require a Contrib Repo Change?
- Yes. - Link to PR:
- No.
Checklist:
- Followed the style guidelines of this project
- Changelogs have been updated
- Unit tests have been added
- Documentation has been updated