Remove memory leaks, with this patch it doesn't leak anymore (Windows… #2125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… Visual Studio, checked using Visual Leak Detector, https://kinddragon.github.io/vld)
This patch uses Py_AtExit to make sure memory is deallocated at the very end.
It may conflict with other platforms/configurations (embedded etc).
The static PyModuleDef def2; assumes there is only one single PYBIND11_MODULE.
In case more modules are allowed, that part of the patch can be removed and a more fancy solution for that deallocation is needed.
These leaks are similar to Issue #2062
However, in my case I'm seeing memory leaks just using a simple plain Python plugin using pybind11 (not embedded).