# PetscObjectRegisterDestroy

Registers a PETSc object to be destroyed when PetscFinalize() is called.

### Synopsis

    #include "petsc.h"
    PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroy(PetscObject obj)

Collective on PetscObject

### Input Parameter

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

### Notes

This is used by, for example, PETSC_VIEWER_XXX_() routines to free the viewer when PETSc ends.

### See Also

PetscObjectRegisterDestroyAll()

Level:developer
Location: src/sys/objects/destroy.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages