Skip to main content
`Ctrl`+`K`

# PetscMallocGetStack

returns a pointer to the stack for the location in the program a call to `PetscMalloc()` was used to obtain that memory

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscMallocGetStack(void *ptr, PetscStack **stack)

Not Collective

## Input Parameter

- ptr - the memory location

## Output Parameter

- stack - the stack indicating where the program allocated this memory

## Note

This only does anything if `-malloc_debug` (or `-malloc_test` if PETSc was configured with debugging) has been used

## See Also

`PetscMallocGetCurrentUsage()`, `PetscMallocView()`, `PetscMalloc()`, `PetscFree()`

## Level

intermediate

## Location

src/sys/memory/mtr.c

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