[petsc-users] Calling MatDestroy on MatGetDiagonalBlock

Dave May dave.mayhem23 at gmail.com
Tue Jan 5 17:20:14 CST 2016

The manpage

indicates the reference counter on the returned matrix (a) isn't

This statement would imply that in the absence of calling
PetscObjectReference() yourself, you should not call MatDestroy() on the
matrix returned.
If you do call MatDestroy(), a double free will occur when you call
MatDestroy() on the parent matrix from which you pulled the block matrix
out of.


On 6 January 2016 at 00:14, Bhalla, Amneet Pal S <amneetb at live.unc.edu>

> Hi Folks,
> Is it safe to call MatDestroy on the sequential matrix returned by
> MatGetDiagonalBlock() after it’s no longer used?
> Thanks,
> — Amneet
> =====================================================
> Amneet Bhalla
> Postdoctoral Research Associate
> Department of Mathematics and McAllister Heart Institute
> University of North Carolina at Chapel Hill
> Email: amneet at unc.edu
> Web:  https://abhalla.web.unc.edu
> =====================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160106/d4758ac5/attachment.html>

More information about the petsc-users mailing list