[#BloombergLP-bdls-MemoryUtil]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::MemoryUtil
:relfileprefix: ../../
:mrdocs:

== Synopsis

Declared in `&lt;bdls&lowbar;memoryutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct MemoryUtil;
----

== Enums

[cols="1"]
|===
| Name
| xref:BloombergLP/bdls/MemoryUtil/Access.adoc[`Access`] 
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/MemoryUtil/allocate.adoc[`allocate`] 
| Allocate an area of memory of the specified size `numBytes`, aligned on a page boundary&period; Return a pointer to allocated memory on success, and a null pointer otherwise&period; Note that the allocated memory is readable and writable, and read&sol;write access to this memory, if revoked, must be restored before deallocation&period;
| xref:BloombergLP/bdls/MemoryUtil/deallocate.adoc[`deallocate`] 
| Deallocate a memory area at the specified `address` previously allocated with the `allocate` method&period; Return 0 on success, and a nonzero value otherwise&period; The behavior is undefined if read or write access to any memory in this area has been revoked and not restored&period; Note that deallocating memory does not change memory protection&period;
| xref:BloombergLP/bdls/MemoryUtil/pageSize.adoc[`pageSize`] 
| Return the memory page size of the platform&period;
| xref:BloombergLP/bdls/MemoryUtil/protect.adoc[`protect`] 
| Change the access protection on a region of memory starting at the specified `address` and `numBytes` long, according to specified `mode`, making memory readable if `(mode &amp; ACCESS&lowbar;READ)` is nonzero and writable if `(mode &amp; ACCESS&lowbar;WRITE)` is nonzero&period; Return 0 on success, and a nonzero value otherwise&period; The behavior is undefined if `addr` is not aligned on a page boundary, if `numBytes` is not a multiple of `pageSize()`, or if `numBytes` is 0&period; Note that some platforms do not support certain protection modes, e&period;g&period;, on some platforms the memory cannot be made writable but unreadable, or readable but non&hyphen;executable&period; On these platforms the actual access protection set on the region might be more permissive than the specified one&period; Also note that most memory allocators do not expect memory protection on allocated memory to be changed, so you must reset protection back to ACCESS&lowbar;READ&lowbar;WRITE before releasing the memory&period;
|===



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