[#BloombergLP-bslma-Allocator-allocate-04] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/Allocator.adoc[Allocator]::allocate :relfileprefix: ../../../ :mrdocs: Return a newly allocated block of memory of the specified `size` bytes. == Synopsis Declared in `<bslma_allocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- virtual void* allocate(xref:BloombergLP/bslma/Allocator/size_type.adoc[size_type] size) = 0; ---- == Description Return a newly allocated block of memory of (at least) the specified positive `size` (in bytes). If `size` is 0, a null pointer is returned with no other effect. If this allocator cannot return the requested number of bytes, then it will throw a `std::bad_alloc` exception in an exception‐enabled build, or else will abort the program in a non‐exception build. The behavior is undefined unless `0 <= size`. Note that the alignment of the address returned conforms to the platform requirement for any object of the specified `size`. Note that this virtual function hides a two‐parameter non‐virtual `allocate` method inherited from `bsl::memory_resource`; to access the inherited function, upcast the object to `bsl::memory_resource&` before calling the base‐class function. [.small]#Created with https://www.mrdocs.com[MrDocs]#