[petsc-users] Is it possible to free extra memory after matassemble?
Matthew Knepley
knepley at gmail.com
Fri Feb 18 06:57:48 CST 2011
On Fri, Feb 18, 2011 at 6:29 AM, Gong Ding <gdiso at ustc.edu> wrote:
>
> ----- Original Message -----
> From: "Matthew Knepley" <knepley at gmail.com>
> To: "PETSc users list" <petsc-users at mcs.anl.gov>
> Sent: Friday, February 18, 2011 7:44 PM
> Subject: Re: [petsc-users] Is it possible to free extra memory after
> matassemble?
>
>
> > 2011/2/18 Gong Ding <gdiso at ustc.edu>
> >
> >> Hi,
> >> After update my FVM code to support higher order, I have to preallocate
> >> more memory when creating the matrix. However, only a few cells
> (determined
> >> at run time) needed to be high order, thus preallocated memory is
> overkill
> >> too much.
> >>
> >> Is it possible to add a function to reassemble the AIJ matrix to free
> the
> >> extra memory?
> >> Or it has already done when MatAssembly is called?
> >>
> >
> > This is done during MatAssemblyEnd(). However, there is no guarantee that
> > the operating system
> > actually returns that memory to general use.
> >
> > Matt
>
> I had checked the function MatAssemblyEnd_SeqAIJ in aij.c.
> It seems it only pack the a, i, j array, but didn't free memory.
> I guess one should malloc three new array with exact size and copy values
> to the new one, and then free the old a, i, j array?
>
If you want that, just do MatCopy().
Matt
--
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110218/cdc9ee4c/attachment.htm>
More information about the petsc-users
mailing list