[petsc-dev] Get/Restore vs Create/Destroy
Matthew Knepley
knepley at gmail.com
Thu Jul 20 10:15:05 CDT 2017
On Thu, Jul 20, 2017 at 9:25 AM, Blaise A Bourdin <bourdin at lsu.edu> wrote:
> Hi,
>
> It’s always been my understanding that and pets object obtained by a
> XXXGetYYY had to be released with a matching XXXRestoreYYY, and that those
> created using XXXCreateYYY had to be destroyed with a YYYDestroy.
>
> It seems that this convention is getting broken in several place. I
> understand that in several situations, this is because the XXXRestoreYYY
> would essentially do nothing.
>
> Is it safe to assume that if a function XXXGetYYY does not have a matching
> XXXRestoreYYY, the instance of PetscYYY does not have to be destroyed in
> any way?
>
Yes. We use Get in two ways:
1) Get a borrowed reference. Then nothing has to be done
2) Get a reference which need extra processing. This requires a matching
Restore
> Is it safe to assume that any instance of a PetscYYY created from
> XXXCreateYYY can be safely destroyed with a YYYDestroy without side effects?
>
Yes.
> If so, should the offending functions be renamed or should something be
> explicitly added to their man page?
We try to always have the matching restore on the manpage. If it is not, we
should fix it.
Thanks,
Matt
>
> Blaise
>
> --
> Department of Mathematics and Center for Computation & Technology
> Louisiana State University, Baton Rouge, LA 70803, USA
> Tel. +1 (225) 578 1612, Fax +1 (225) 578 4276 http://www.math.lsu.edu/~
> bourdin
>
>
>
>
>
>
>
>
--
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
http://www.caam.rice.edu/~mk51/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20170720/b7d495bd/attachment.html>
More information about the petsc-dev
mailing list