Re: [eigen] Memory leaks

[ Thread Index | Date Index | More Archives ]

On Tue, Apr 14, 2015 at 5:09 PM, Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Am 14.04.2015 um 16:06 schrieb Mathieu Dutour:
I obtain the leak by writing
MyVector<T> V1=eMat.row(iRow);

I eliminate the leak by doing
MyVector<T> V1(nbCol);

I can confirm this, the problem is in the constructor of Matrix:
    EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
             : Base(other.rows() * other..cols(), other.rows(), other.cols())

here Base is called with rows and cols of `other`, even though `other` needs to be transposed. Base then does not assert that cols==1.

yes, we could add internal assertions for that, and also to check that size == rows*cols in DenseStorage.
Is there a reason to call Base(size, rows, cols) at all? The call to
should do all appropriate resizing, does it not? 

I've removed that line and my test-case passes now. I'm running the test-suite now to see if this has any unforeseen side-effects.

yes, this seems to be the simplest solution.


Mail converted by MHonArc 2.6.19+