# PetscObjectDelayedDestroy
Adds an object to a data structure for later destruction. 
## Synopsis
```
PetscErrorCode PetscObjectDelayedDestroy(PetscObject *obj)
```
Not Collective


## Input Parameters

- ***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.




## See Also
 `PetscGarbageCleanup()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/garbage.c.html#PetscObjectDelayedDestroy">src/sys/objects/garbage.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/garbage.c)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
