:orphan:
# PetscObjectDestroy
Destroys any `PetscObject`, regardless of the type. 
## Synopsis
```
#include "petscsys.h"    
PetscErrorCode PetscObjectDestroy(PetscObject *obj)
```
Collective


## Input Parameter

- ***obj -*** any PETSc object, for example a `Vec`, `Mat` or `KSP`.
This must be cast with a (`PetscObject`*), for example,
`PetscObjectDestroy`((`PetscObject`*)&mat);





## See Also
 `PetscObject`

## Level
beginner

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


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


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