This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to clear a dolfin::Matrix in C++ programming

0 votes

I have a dolfin::Matrix, which is a big one, say global stiffness matrix. But after solving the linear equations, this is not needed. I would like to clear it for saving storage. Could anyone tell me how to get it? Thanks.

XZ

asked Nov 8, 2013 by xzhao99 FEniCS Novice (270 points)

1 Answer

0 votes

Reset a smart pointer to your matrix or let the matrix come out of scope.

answered Nov 8, 2013 by Jan Blechta FEniCS Expert (51,420 points)

THank you. If I use a shared_ptr spm to create a matrix spm(new Matrix), after spm->reset() operation, the pointer will NOT point to the matrix, but will the matrix still remain in the memory? I think the smart pointer can automatically delete it, but not sure.

XZ

Yes, the object is deleted whenever its reference count becomes zero.

...