:orphan: # PetscFree Frees memory ## Synopsis ``` #include PetscErrorCode PetscFree(void *memory) ``` Not Collective ## Input Parameter - ***memory -*** memory to free (the pointer is ALWAYS set to `NULL` upon success) ## Note Do not free memory obtained with `PetscMalloc2()`, `PetscCalloc2()` etc, they must be freed with `PetscFree2()` etc. It is safe to call `PetscFree()` on a `NULL` pointer. ## See Also `PetscNew()`, `PetscMalloc()`, `PetscMalloc1()`, `PetscCalloc1()` ## Level beginner ## Location include/petscsys.h ## Examples src/dm/field/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex10.c
src/dm/impls/plex/tutorials/ex14.c
src/dm/impls/plex/tutorials/ex6.c
src/dm/impls/plex/tutorials/ex8.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/label/tutorials/ex1.c
src/dm/tutorials/ex14.c
src/dm/tutorials/ex20.c
src/dm/tutorials/ex21.c
src/dm/tutorials/ex26.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsys.h) [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)