Skip to main content
`Ctrl`+`K`

# PetscObjectDelayedDestroy

Adds an object to a data structure for later destruction.

## Synopsis

    PetscErrorCode PetscObjectDelayedDestroy(PetscObject *obj)

Not Collective

## Input Parameter

- obj - object to be destroyed

## Notes

Analogue to `PetscObjectDestroy()` for use in managed languages.

A PETSc object is given a creation index at initialisation based on the communicator it was created on and the order in which it is created. When this function is passed a PETSc object, a pointer to the object is stashed on a garbage dictionary (`PetscHMapObj`) which is keyed by its creation index.

Objects stashed on this garbage dictionary can later be destroyed with a call to `PetscGarbageCleanup()`.

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

Serial objects (that have a communicator with size 1) are destroyed eagerly since deadlocks cannot occur.

## See Also

`PetscGarbageCleanup()`, `PetscObjectDestroy()`

## 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