[petsc-users] free unused allocated nonzeros after overestimating preallocation

Jed Brown jed at 59A2.org
Mon May 3 08:40:41 CDT 2010


On Mon, 3 May 2010 08:20:44 -0500, Matthew Knepley <knepley at gmail.com> wrote:
> MatAssemblyBegin/End() frees the unused memory, so you must be
> calculating the amount of memory needed incorrectly.

It compacts the values but does not free the extra memory.  It would be
easy to add a matrix option to allocate new space for the entries and
column indices, then copy the entries over, but requires too much memory
to do it by default.

MatDuplicate on the other hand only allocates for the used values, but
copies the "maxnz" field so it will incorrectly report more allocation
than there really is.

Jed


More information about the petsc-users mailing list