On Sun, Aug 25, 2013 at 7:38 AM, Michael Povolotskyi <[email protected]>wrote:
> On 8/23/2013 7:37 PM, Jed Brown wrote: > >> Barry Smith <[email protected]> writes: >> >>> We call free() at that point. But not that in Unix this does not >>> mean the memory is returned to the operating system so you will not >>> see the process memory go down. If you then allocate new objects >>> they will reuse this memory. >>> >> Also note that MatDestroy only releases a references, so if another >> object still holds a reference to your matrix, nothing will be freed. >> > Thank you! > Just to clarify: if a code reads like this: > > Mat A; > MatCreate(MPI_COMM_WORLD, &A); > > Mat B = A; > .... > MatDestroy(&B); > > Will the free() function be called for the memory that contains the matrix > data in this case? > Yes, it will. You might want Mat B = A; PetscObjectReference((PetscObject) B); so that you also need MatDestroy(B); Matt > Thank you, > Michael. > -- 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
