Closed JannikIrmai closed 1 year ago
Thank you for reporting this! And thank you for including the code to reproduce, that makes things a lot easier.
I added the DIPlib tag because my first instinct was that this is a memory leak in the library, but I don’t see any significant difference in the code between EigenDecomposition
and SmallestEigenvector
. So maybe this is an issue with the bindings after all.
I will try to reproduce the problem and run under valgrind to see where the memory is lost.
Indeed, this was a bug in the Python bindings. A reference counting issue.
PyDIP (diblib 3.4.0)
Describe the bug When using the EigenDecomposition method to compute Eigen values and vectors simultaneously there seems to be a memory leak.
To Reproduce
To reproduce this I generate a random 3D image, compute the Hessian of that image and then compute the Eigen decomposition of the hessian. I do this three times in a row and delete the results after each iteration. However, the memory is not freed.
In each iteration the memory usage increases when the hessian and Eigen decomposition are computed. However, after the iteration the memory usage is only reduced by the amount of the hessian and not the Eigen decomposition.
If, instead of using EigenDecomposition I use the Eigenvalues and, for example, SmallestEigenvector functions then the memory is freed:
System information: