Skip to main content
Ctrl+K
PETSc v3.26.0-2-g3c5cfaeaff0b documentation - Home
  • Overview
  • Install
  • Tutorials
  • User-Guide
  • C/Fortran API
  • petsc4py API
  • FAQ
  • Community
  • Developers
  • Misc.
  • GitLab
  • Overview
  • Install
  • Tutorials
  • User-Guide
  • C/Fortran API
  • petsc4py API
  • FAQ
  • Community
  • Developers
  • Misc.
  • GitLab
  • PetscFree

PetscFree#

Frees memory

Synopsis#

#include <petscsys.h>
PetscErrorCode PetscFree(void *memory)

Not Collective

Input Parameter#

  • memory - memory to free (the pointer is ALWAYS set to NULL upon success)

Notes#

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/sys/classes/random/tutorials/ex1.c
src/sys/classes/random/tutorials/ex2.c
src/sys/tutorials/ex7.c
src/sys/classes/random/tests/ex3.c
src/sys/classes/viewer/tests/ex8.c
src/sys/error/tests/ex2.c
src/sys/objects/device/tests/ex2hip.hip.cxx
src/sys/tests/ex10.c
src/sys/tests/ex12.c
src/sys/tests/ex21.c


Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

On this page
  • Synopsis
  • Input Parameter
  • Notes
  • See Also
  • Level
  • Location
  • Examples
Edit on GitLab
Show Source

© Copyright 1991-2026, UChicago Argonne, LLC and the PETSc Development Team.

Created using Sphinx 7.3.7.

Built with the PyData Sphinx Theme 0.15.1.

Last updated on 2026-09-28T23:19:25-0500 (v3.26.0-2-g3c5cfaeaff0b).