MeVisLab / pythonqt

Dynamic Python binding for Qt Applications
https://mevislab.github.io/pythonqt/
GNU Lesser General Public License v2.1
251 stars 89 forks source link

Fix memory leak and add memory tests #229

Closed MinyazevR closed 3 months ago

MinyazevR commented 3 months ago
  1. PyUnicode_FromString returns a new reference, thus memory leak took place and is fixed.
  2. To diagnose such leaks, basic memory tests are implemented, that to be extended later. To run these memory tests the PYTHONQT_RUN_ONLY_MEMORY_TESTS environment variable should be used.
  3. These tiny specialized memory tests are temporary useful until memleaks are fixed in PythonQt::cleanup for general main tests.
  4. So, this PR adds a CI step to run mentioned memory tests with Leak Sanitizer turned on via ASAN_OPTIONS=detect_leaks=1.
iakov commented 3 months ago

Thank you very much. This PR is connected to #201 Default tests leak a lot, that makes it difficult to test and fix leaks in the library itself. I agree that small separate test case is temporarily required, nevertheless the main test should be fixed too later.