:orphan:
# 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 <true or false> -*** 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 <filename> -*** print a list of all memory that has not been freed
- ***-malloc no -*** (deprecated) same as `-malloc_debug no`
- ***-malloc_log -*** (deprecated) same as `-malloc_view`





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


## See Also
 `CHKMEMQ()`, `PetscMallocValidate()`, `PetscMallocGetDebug()`, `PetscMalloc()`, `PetscFree()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/memory/mtr.c.html#PetscMallocSetDebug">src/sys/memory/mtr.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/memory/mtr.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)  
