PetscMallocSetDebug — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# PetscMallocSetDebug

Set’s PETSc memory debugging

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscMallocSetDebug(PetscBool eachcall, PetscBool initializenan)

Not Collective

## Input Parameters

- eachcall - checks the entire heap of allocated memory for issues on each call to `PetscMalloc()` and `PetscFree()`, slow

- initializenan - initializes all memory with `NaN` to catch use of uninitialized floating point arrays

## Options Database Keys

- -malloc_debug - turns on or off debugging

- -malloc_test - turns on all debugging if PETSc was configured with debugging including `-malloc_dump`, otherwise ignored

- -malloc_view_threshold t - log only allocations larger than t

- -malloc_dump - print a list of all memory that has not been freed, in `PetscFinalize()`

## Note

This is called in `PetscInitialize()` and should not be called elsewhere

## See Also

`CHKMEMQ`, `PetscMallocValidate()`, `PetscMallocGetDebug()`, `PetscMalloc()`, `PetscFree()`

## Level

developer

## Location

src/sys/memory/mtr.c

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