This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Possible Memory leak

Tags: None
(comma "," separated)
alexanderwerner
Registered Member
Posts
11
Karma
0

Possible Memory leak

Wed Mar 21, 2018 7:10 pm
Hi,

I think I found a memory leak, however no minimal example of it yet. Hopefully tomorrow. The calling code looks like this:
Code: Select all
     SparseMatrix<double,1> fun() {
          SparseMatrix<double,1> x(2,3);
          // insert
          return x;
     }

     SparseMatrix<double,1> y(3,3);
     m.middleRows(1,2) = fun();

which calls Eigen::internal::sparse_matrix_block_impl::operator=. There the gperftools heap profiler points me to line 148 in Eigen/src/SparseCore/SparseBlock.h
Code: Select all
144:       bool update_trailing_pointers = false;
145:       if(nnz>free_size)
146:       {
147:         // realloc manually to reduce copies
148:         typename SparseMatrixType::Storage newdata(m_matrix.data().allocatedSize() - block_size + nnz);
149:
150:         internal::smart_copy(m_matrix.valuePtr(),       m_matrix.valuePtr() + start,      newdata.valuePtr());
151:         internal::smart_copy(m_matrix.innerIndexPtr(),  m_matrix.innerIndexPtr() + start, newdata.indexPtr());
152:
153:         internal::smart_copy(tmp.valuePtr() + tmp_start,      tmp.valuePtr() + tmp_start + nnz,       newdata.valuePtr() + start);
154:         internal::smart_copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz,  newdata.indexPtr() + start);
155:
156:         internal::smart_copy(matrix.valuePtr()+end,       matrix.valuePtr()+end + tail_size,      newdata.valuePtr()+start+nnz);
157:         internal::smart_copy(matrix.innerIndexPtr()+end,  matrix.innerIndexPtr()+end + tail_size, newdata.indexPtr()+start+nnz);
158:
159:         newdata.resize(m_matrix.outerIndexPtr()[m_matrix.outerSize()] - block_size + nnz);
160:
161:         matrix.data().swap(newdata);
162:
163:         update_trailing_pointers = true;
164:       }


Used version is 3.3.4.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]