:orphan:
# PetscMallocSetCoalesce
Use coalesced `PetscMalloc()` when allocating groups of objects, that is when using `PetscMallocN()` 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscMallocSetCoalesce(PetscBool coalesce)
```
Not Collective


## Input Parameter

- ***coalesce -*** `PETSC_TRUE` to use coalesced malloc for multi-memory allocation.



## Options Database Key

- ***-malloc_coalesce -*** turn coalesced malloc on or off





## Notes
PETSc uses coalesced malloc by default for optimized builds and not for debugging builds.

This default can be changed via the command-line option `-malloc_coalesce` or by calling this function.

This function can only be called immediately after `PetscInitialize()`


## See Also
 `PetscMallocA()`, `PetscMalloc()`, `PetscFree()`

## Level
developer

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


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