dlr-gtlab / python-module

GTlab Module for embadding Python into GTlab
0 stars 0 forks source link

Implemented C++ RAII wrapper to reduce memleaks - [merged] #547

Closed rainman110 closed 4 months ago

rainman110 commented 8 months ago

_Merges python_cppapi -> master

This refactoring provides RAII style wrappers for PyObject. In fact, using these changes, I could reduce many memory leaks (see #264). This wrapper should make the manual refcounting unnecessary and hence should reduce the number of potential programming errors, making the code also much more thread safe.

I tested the code using address sanitizer, showing no more memory leaks.

Closes #256, #263, #264

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 3 commits

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

added 17 commits

Compare with previous version

rainman110 commented 8 months ago

marked this merge request as ready

rainman110 commented 8 months ago

added 4 commits

Compare with previous version

rainman110 commented 8 months ago

added 8 commits

Compare with previous version

rainman110 commented 8 months ago

added 2 commits

Compare with previous version

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

In GitLab by @marvinoe21 on Mar 13, 2024, 10:37

Commented on src/module/utilities/pythonextensions/gtpy_propertysetter.h line 19

In a Python Task script create a calculator and call a setter method to set a property. E.g.:

pythonScriptEditor = GtpyScriptCalculator("Python Script Editor")
pythonScriptEditor.setScript("print('Hello')")

In GtpyExtendedWrapper_getattro this function is called to create setter methods for GtProperties of GtObjects.

rainman110 commented 8 months ago

In GitLab by @marvinoe21 on Mar 13, 2024, 10:43

Commented on src/module/utilities/pythonextensions/gtpy_propertysetter.cpp line 213

@rainman110 You're right! It looks like a leak.

rainman110 commented 8 months ago

In GitLab by @marvinoe21 on Mar 13, 2024, 10:59

Commented on src/module/gt_python.cpp line 302

Should these shared functions be merged into the master?

rainman110 commented 8 months ago

I would say yes. They are only active in dev mode. Can be used for testing.

rainman110 commented 8 months ago

resolved all threads

rainman110 commented 8 months ago

changed this line in version 19 of the diff

rainman110 commented 8 months ago

changed this line in version 19 of the diff

rainman110 commented 8 months ago

added 1 commit

Compare with previous version

rainman110 commented 8 months ago

mentioned in commit 17787a89e7f460a22c7d972c60727c2b2dc3e704