[#BloombergLP-bslma-Default-setGlobalAllocator]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/Default.adoc[Default]::setGlobalAllocator
:relfileprefix: ../../../
:mrdocs:

Unconditionally set the address of the global allocator&period;

== Synopsis

Declared in `&lt;bslma&lowbar;default&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
xref:BloombergLP/bslma/Allocator.adoc[Allocator]*
setGlobalAllocator(xref:BloombergLP/bslma/Allocator.adoc[Allocator]* basicAllocator);
----

== Description

Unconditionally set the address of the global allocator to the specified `basicAllocator`, or to the address of the `NewDeleteAllocator` singleton if `basicAllocator` is 0&period; Return the address of the global allocator in effect immediately before calling this method&period; The behavior is undefined unless `basicAllocator` is 0 or is the address of an allocator with sufficient lifetime to satisfy all global allocation requests within this process, and unless there is only one thread started within this process&period; Note that prior to the first call to this method, the address of the global allocator is that of the `NewDeleteAllocator` singleton&period; Also note that this method is intended for use _only_ by the _owner_ of `main` (or for use in _testing_) where the caller affirmatively takes responsibility for the behavior of all clients of the global allocator, and should _not_ be used for any other purpose&period;

== Return Value

address of the global allocator previously in effect

== Parameters

[cols="1,4"]
|===
| Name| Description
| *basicAllocator*
| allocator to install as the global allocator
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
