Skip to main content
`Ctrl`+`K`

# PetscMallocDump

Dumps the currently allocated memory blocks to a file. The information printed is: size of space (in bytes), address of space, id of space, file in which space was allocated, and line number at which it was allocated.

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscMallocDump(FILE *fp)

Not Collective

## Input Parameter

- fp - file pointer. If `fp` is `NULL`, `stdout` is assumed.

## Options Database Key

- -malloc_dump - Print summary of unfreed memory during call to `PetscFinalize()`, writing to filename if given

## Notes

Uses `MPI_COMM_WORLD` to display rank, because this may be called in `PetscFinalize()` after `PETSC_COMM_WORLD` has been freed.

When called in `PetscFinalize()` dumps only the allocations that have not been properly freed

`PetscMallocView()` prints a list of all memory ever allocated

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

## Fortran Notes

The calling sequence is `PetscMallocDump`(PetscErrorCode ierr). A `fp` parameter is not supported.

## Developer Notes

This should be absorbed into `PetscMallocView()`

## See Also

`PetscMallocGetCurrentUsage()`, `PetscMallocView()`, `PetscMallocViewSet()`, `PetscMallocValidate()`, `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