PetscGarbageCleanup — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# PetscGarbageCleanup

Destroys objects placed in the garbage by `PetscObjectDelayedDestroy()`.

## Synopsis

    PetscErrorCode PetscGarbageCleanup(MPI_Comm comm)

Collective

## Input Parameter

- comm - MPI communicator over which to perform collective cleanup

## Notes

Implements a collective garbage collection. A per- MPI communicator garbage dictionary is created to store references to objects destroyed using `PetscObjectDelayedDestroy()`. Objects that appear in this dictionary on all MPI processes can be destroyed by calling `PetscGarbageCleanup()`.

This is done as follows:

1. Keys of the garbage dictionary, which correspond to the creation indices of the objects stashed, are sorted.

2. A collective intersection of dictionary keys is performed by all ranks in the communicator.

3. The intersection is broadcast back to all ranks in the communicator.

4. The objects on the dictionary are collectively destroyed in creation index order using a call to PetscObjectDestroy().

This function is intended for use with managed languages such as Python or Julia, which may not destroy objects in a deterministic order.

## See Also

`PetscObjectDelayedDestroy()`

## Level

developer

## Location

src/sys/objects/garbage.c

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages