<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.11.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>mi-malloc: Arenas</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="mimalloc-doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="mimalloc-logo.svg"/></td>
<td id="projectalign">
<div id="projectname">mi-malloc<span id="projectnumber"> 1.8/2.1</span>
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"> </span>
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.11.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function(){initNavTree('group__arenas.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#typedef-members">Typedefs</a> |
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">Arenas</div></div>
</div><!--header-->
<div class="contents">
<p>Arenas are large memory areas (usually 1GiB+) from which mimalloc allocates memory.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga99fe38650d0b02e0e0f89ee024db91d3" id="r_ga99fe38650d0b02e0e0f89ee024db91d3"><td class="memItemLeft" align="right" valign="top">typedef int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a></td></tr>
<tr class="memdesc:ga99fe38650d0b02e0e0f89ee024db91d3"><td class="mdescLeft"> </td><td class="mdescRight">Each arena has an associated identifier. <br /></td></tr>
<tr class="separator:ga99fe38650d0b02e0e0f89ee024db91d3"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga00ec3324b6b2591c7fe3677baa30a767" id="r_ga00ec3324b6b2591c7fe3677baa30a767"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga00ec3324b6b2591c7fe3677baa30a767">mi_reserve_os_memory</a> (size_t size, bool commit, bool allow_large)</td></tr>
<tr class="memdesc:ga00ec3324b6b2591c7fe3677baa30a767"><td class="mdescLeft"> </td><td class="mdescRight">Reserve OS memory for use by mimalloc. <br /></td></tr>
<tr class="separator:ga00ec3324b6b2591c7fe3677baa30a767"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga32f519797fd9a81acb4f52d36e6d751b" id="r_ga32f519797fd9a81acb4f52d36e6d751b"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga32f519797fd9a81acb4f52d36e6d751b">mi_reserve_os_memory_ex</a> (size_t size, bool commit, bool allow_large, bool exclusive, <a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> *arena_id)</td></tr>
<tr class="memdesc:ga32f519797fd9a81acb4f52d36e6d751b"><td class="mdescLeft"> </td><td class="mdescRight">Reserve OS memory to be managed in an arena. <br /></td></tr>
<tr class="separator:ga32f519797fd9a81acb4f52d36e6d751b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga3132f521fb756fc0e8ec0b74fb58df50" id="r_ga3132f521fb756fc0e8ec0b74fb58df50"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga3132f521fb756fc0e8ec0b74fb58df50">mi_reserve_huge_os_pages_interleave</a> (size_t pages, size_t numa_nodes, size_t timeout_msecs)</td></tr>
<tr class="memdesc:ga3132f521fb756fc0e8ec0b74fb58df50"><td class="mdescLeft"> </td><td class="mdescRight">Reserve <em>pages</em> of huge OS pages (1GiB) evenly divided over <em>numa_nodes</em> nodes, but stops after at most <code>timeout_msecs</code> seconds. <br /></td></tr>
<tr class="separator:ga3132f521fb756fc0e8ec0b74fb58df50"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga7795a13d20087447281858d2c771cca1" id="r_ga7795a13d20087447281858d2c771cca1"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga7795a13d20087447281858d2c771cca1">mi_reserve_huge_os_pages_at</a> (size_t pages, int numa_node, size_t timeout_msecs)</td></tr>
<tr class="memdesc:ga7795a13d20087447281858d2c771cca1"><td class="mdescLeft"> </td><td class="mdescRight">Reserve <em>pages</em> of huge OS pages (1GiB) at a specific <em>numa_node</em>, but stops after at most <code>timeout_msecs</code> seconds. <br /></td></tr>
<tr class="separator:ga7795a13d20087447281858d2c771cca1"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga591aab1c2bc2ca920e33f0f9f9cb5c52" id="r_ga591aab1c2bc2ca920e33f0f9f9cb5c52"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga591aab1c2bc2ca920e33f0f9f9cb5c52">mi_reserve_huge_os_pages_at_ex</a> (size_t pages, int numa_node, size_t timeout_msecs, bool exclusive, <a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> *arena_id)</td></tr>
<tr class="memdesc:ga591aab1c2bc2ca920e33f0f9f9cb5c52"><td class="mdescLeft"> </td><td class="mdescRight">Reserve huge OS pages (1GiB) into a single arena. <br /></td></tr>
<tr class="separator:ga591aab1c2bc2ca920e33f0f9f9cb5c52"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaa1a59464dbf3bc972d34fca0f86668fc" id="r_gaa1a59464dbf3bc972d34fca0f86668fc"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="#gaa1a59464dbf3bc972d34fca0f86668fc">mi_arena_min_alignment</a> (void)</td></tr>
<tr class="memdesc:gaa1a59464dbf3bc972d34fca0f86668fc"><td class="mdescLeft"> </td><td class="mdescRight">Return the minimal alignment required for managed OS memory. <br /></td></tr>
<tr class="separator:gaa1a59464dbf3bc972d34fca0f86668fc"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga4c6486a1fdcd7a423b5f25fe4be8e0cf" id="r_ga4c6486a1fdcd7a423b5f25fe4be8e0cf"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga4c6486a1fdcd7a423b5f25fe4be8e0cf">mi_manage_os_memory</a> (void *start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node)</td></tr>
<tr class="memdesc:ga4c6486a1fdcd7a423b5f25fe4be8e0cf"><td class="mdescLeft"> </td><td class="mdescRight">Manage a particular memory area for use by mimalloc. <br /></td></tr>
<tr class="separator:ga4c6486a1fdcd7a423b5f25fe4be8e0cf"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga41ce8525d77bbb60f618fa1029994f6e" id="r_ga41ce8525d77bbb60f618fa1029994f6e"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga41ce8525d77bbb60f618fa1029994f6e">mi_manage_os_memory_ex</a> (void *start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node, bool exclusive, <a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> *arena_id)</td></tr>
<tr class="memdesc:ga41ce8525d77bbb60f618fa1029994f6e"><td class="mdescLeft"> </td><td class="mdescRight">Manage externally allocated memory as a mimalloc arena. <br /></td></tr>
<tr class="separator:ga41ce8525d77bbb60f618fa1029994f6e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga98cda17aa7adeda8b213382af8e7810b" id="r_ga98cda17aa7adeda8b213382af8e7810b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga98cda17aa7adeda8b213382af8e7810b">mi_debug_show_arenas</a> (void)</td></tr>
<tr class="memdesc:ga98cda17aa7adeda8b213382af8e7810b"><td class="mdescLeft"> </td><td class="mdescRight">Show all current arena's. <br /></td></tr>
<tr class="separator:ga98cda17aa7adeda8b213382af8e7810b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga9a25a00a22151619a0be91a10af7787f" id="r_ga9a25a00a22151619a0be91a10af7787f"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga9a25a00a22151619a0be91a10af7787f">mi_arena_area</a> (<a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> arena_id, size_t *size)</td></tr>
<tr class="memdesc:ga9a25a00a22151619a0be91a10af7787f"><td class="mdescLeft"> </td><td class="mdescRight">Return the start and size of an arena. <br /></td></tr>
<tr class="separator:ga9a25a00a22151619a0be91a10af7787f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaaf2d9976576d5efd5544be12848af949" id="r_gaaf2d9976576d5efd5544be12848af949"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="#gaaf2d9976576d5efd5544be12848af949">mi_heap_new_in_arena</a> (<a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> arena_id)</td></tr>
<tr class="memdesc:gaaf2d9976576d5efd5544be12848af949"><td class="mdescLeft"> </td><td class="mdescRight">Create a new heap that only allocates in the specified arena. <br /></td></tr>
<tr class="separator:gaaf2d9976576d5efd5544be12848af949"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga3ae360583f4351aa5267ee7e43008faf" id="r_ga3ae360583f4351aa5267ee7e43008faf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga3ae360583f4351aa5267ee7e43008faf">mi_heap_new_ex</a> (int heap_tag, bool allow_destroy, <a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> arena_id)</td></tr>
<tr class="memdesc:ga3ae360583f4351aa5267ee7e43008faf"><td class="mdescLeft"> </td><td class="mdescRight"><b>v1</b>,<b>v2</b>: Create a new heap. <br /></td></tr>
<tr class="separator:ga3ae360583f4351aa5267ee7e43008faf"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Arenas are large memory areas (usually 1GiB+) from which mimalloc allocates memory. </p>
<p>The arenas are usually allocated on-demand from the OS but can be reserved explicitly. It is also possible to give previously allocated memory to mimalloc to manage. Heaps can be associated with a specific arena to only allocate memory from that arena. </p>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="ga99fe38650d0b02e0e0f89ee024db91d3" name="ga99fe38650d0b02e0e0f89ee024db91d3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga99fe38650d0b02e0e0f89ee024db91d3">◆ </a></span>mi_arena_id_t</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef int <a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>Each arena has an associated identifier. </p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga9a25a00a22151619a0be91a10af7787f" name="ga9a25a00a22151619a0be91a10af7787f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9a25a00a22151619a0be91a10af7787f">◆ </a></span>mi_arena_area()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * mi_arena_area </td>
<td>(</td>
<td class="paramtype"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a></td> <td class="paramname"><span class="paramname"><em>arena_id</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t *</td> <td class="paramname"><span class="paramname"><em>size</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Return the start and size of an arena. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">arena_id</td><td>The arena identifier. </td></tr>
<tr><td class="paramname">size</td><td>Returned size in bytes of the (virtual) arena area. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>base address of the arena. </dd></dl>
</div>
</div>
<a id="gaa1a59464dbf3bc972d34fca0f86668fc" name="gaa1a59464dbf3bc972d34fca0f86668fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa1a59464dbf3bc972d34fca0f86668fc">◆ </a></span>mi_arena_min_alignment()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t mi_arena_min_alignment </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Return the minimal alignment required for managed OS memory. </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga4c6486a1fdcd7a423b5f25fe4be8e0cf" title="Manage a particular memory area for use by mimalloc.">mi_manage_os_memory()</a>, <a class="el" href="#ga41ce8525d77bbb60f618fa1029994f6e" title="Manage externally allocated memory as a mimalloc arena.">mi_manage_os_memory_ex()</a> </dd></dl>
</div>
</div>
<a id="ga98cda17aa7adeda8b213382af8e7810b" name="ga98cda17aa7adeda8b213382af8e7810b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga98cda17aa7adeda8b213382af8e7810b">◆ </a></span>mi_debug_show_arenas()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_debug_show_arenas </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Show all current arena's. </p>
</div>
</div>
<a id="ga3ae360583f4351aa5267ee7e43008faf" name="ga3ae360583f4351aa5267ee7e43008faf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3ae360583f4351aa5267ee7e43008faf">◆ </a></span>mi_heap_new_ex()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> * mi_heap_new_ex </td>
<td>(</td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>heap_tag</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>allow_destroy</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a></td> <td class="paramname"><span class="paramname"><em>arena_id</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p><b>v1</b>,<b>v2</b>: Create a new heap. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">heap_tag</td><td>The heap tag associated with this heap; heaps only reclaim memory between heaps with the same tag. </td></tr>
<tr><td class="paramname">allow_destroy</td><td>Is <em>mi_heap_destroy</em> allowed? Not allowing this allows the heap to reclaim memory from terminated threads. </td></tr>
<tr><td class="paramname">arena_id</td><td>If not 0, the heap will only allocate from the specified arena. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A new heap or <code>NULL</code> on failure.</dd></dl>
<p>The <em>arena_id</em> can be used by runtimes to allocate only in a specified pre-reserved arena. This is used for example for a compressed pointer heap in Koka. The <em>heap_tag</em> enables heaps to keep objects of a certain type isolated to heaps with that tag. This is used for example in the CPython integration. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="#gaaf2d9976576d5efd5544be12848af949" title="Create a new heap that only allocates in the specified arena.">mi_heap_new_in_arena()</a> for <b>v3</b> </dd></dl>
</div>
</div>
<a id="gaaf2d9976576d5efd5544be12848af949" name="gaaf2d9976576d5efd5544be12848af949"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaf2d9976576d5efd5544be12848af949">◆ </a></span>mi_heap_new_in_arena()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> * mi_heap_new_in_arena </td>
<td>(</td>
<td class="paramtype"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a></td> <td class="paramname"><span class="paramname"><em>arena_id</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Create a new heap that only allocates in the specified arena. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">arena_id</td><td>The arena identifier. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The new heap or <code>NULL</code>. </dd></dl>
</div>
</div>
<a id="ga4c6486a1fdcd7a423b5f25fe4be8e0cf" name="ga4c6486a1fdcd7a423b5f25fe4be8e0cf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4c6486a1fdcd7a423b5f25fe4be8e0cf">◆ </a></span>mi_manage_os_memory()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool mi_manage_os_memory </td>
<td>(</td>
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>start</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>is_committed</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>is_large</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>is_zero</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>numa_node</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Manage a particular memory area for use by mimalloc. </p>
<p>This is just like <code>mi_reserve_os_memory</code> except that the area should already be allocated in some manner and available for use my mimalloc. </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">start</td><td>Start of the memory area </td></tr>
<tr><td class="paramname">size</td><td>The size of the memory area. </td></tr>
<tr><td class="paramname">is_committed</td><td>Is the area already committed? </td></tr>
<tr><td class="paramname">is_large</td><td>Does it consist of large OS pages? Set this to <em>true</em> as well for memory that should not be decommitted or protected (like rdma etc.) </td></tr>
<tr><td class="paramname">is_zero</td><td>Does the area consists of zero's? </td></tr>
<tr><td class="paramname">numa_node</td><td>Possible associated numa node or <code>-1</code>. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><em>true</em> if successful, and <em>false</em> on error. </dd></dl>
</div>
</div>
<a id="ga41ce8525d77bbb60f618fa1029994f6e" name="ga41ce8525d77bbb60f618fa1029994f6e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga41ce8525d77bbb60f618fa1029994f6e">◆ </a></span>mi_manage_os_memory_ex()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool mi_manage_os_memory_ex </td>
<td>(</td>
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>start</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>is_committed</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>is_large</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>is_zero</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>numa_node</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>exclusive</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> *</td> <td class="paramname"><span class="paramname"><em>arena_id</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Manage externally allocated memory as a mimalloc arena. </p>
<p>This memory will not be freed by mimalloc. </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">start</td><td>Start address of the area. </td></tr>
<tr><td class="paramname">size</td><td>Size in bytes of the area. </td></tr>
<tr><td class="paramname">is_committed</td><td>Is the memory already committed? </td></tr>
<tr><td class="paramname">is_large</td><td>Does it consist of (pinned) large OS pages? </td></tr>
<tr><td class="paramname">is_zero</td><td>Is the memory zero-initialized? </td></tr>
<tr><td class="paramname">numa_node</td><td>Associated NUMA node, or -1 to have no NUMA preference. </td></tr>
<tr><td class="paramname">exclusive</td><td>Is the arena exclusive (where only heaps associated with the arena can allocate in it) </td></tr>
<tr><td class="paramname">arena_id</td><td>The new arena identifier. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if successful. </dd></dl>
</div>
</div>
<a id="ga7795a13d20087447281858d2c771cca1" name="ga7795a13d20087447281858d2c771cca1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7795a13d20087447281858d2c771cca1">◆ </a></span>mi_reserve_huge_os_pages_at()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mi_reserve_huge_os_pages_at </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>pages</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>numa_node</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>timeout_msecs</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reserve <em>pages</em> of huge OS pages (1GiB) at a specific <em>numa_node</em>, but stops after at most <code>timeout_msecs</code> seconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pages</td><td>The number of 1GiB pages to reserve. </td></tr>
<tr><td class="paramname">numa_node</td><td>The NUMA node where the memory is reserved (start at 0). Use -1 for no affinity. </td></tr>
<tr><td class="paramname">timeout_msecs</td><td>Maximum number of milli-seconds to try reserving, or 0 for no timeout. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, <em>ENOMEM</em> if running out of memory, or <em>ETIMEDOUT</em> if timed out.</dd></dl>
<p>The reserved memory is used by mimalloc to satisfy allocations. May quit before <em>timeout_msecs</em> are expired if it estimates it will take more than 1.5 times <em>timeout_msecs</em>. The time limit is needed because on some operating systems it can take a long time to reserve contiguous memory if the physical memory is fragmented. </p>
</div>
</div>
<a id="ga591aab1c2bc2ca920e33f0f9f9cb5c52" name="ga591aab1c2bc2ca920e33f0f9f9cb5c52"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga591aab1c2bc2ca920e33f0f9f9cb5c52">◆ </a></span>mi_reserve_huge_os_pages_at_ex()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mi_reserve_huge_os_pages_at_ex </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>pages</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>numa_node</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>timeout_msecs</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>exclusive</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> *</td> <td class="paramname"><span class="paramname"><em>arena_id</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reserve huge OS pages (1GiB) into a single arena. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pages</td><td>Number of 1GiB pages to reserve. </td></tr>
<tr><td class="paramname">numa_node</td><td>The associated NUMA node, or -1 for no NUMA preference. </td></tr>
<tr><td class="paramname">timeout_msecs</td><td>Max amount of milli-seconds this operation is allowed to take. (0 is infinite) </td></tr>
<tr><td class="paramname">exclusive</td><td>If exclusive, only a heap associated with this arena can allocate in it. </td></tr>
<tr><td class="paramname">arena_id</td><td>The arena identifier. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, <em>ENOMEM</em> if running out of memory, or <em>ETIMEDOUT</em> if timed out. </dd></dl>
</div>
</div>
<a id="ga3132f521fb756fc0e8ec0b74fb58df50" name="ga3132f521fb756fc0e8ec0b74fb58df50"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3132f521fb756fc0e8ec0b74fb58df50">◆ </a></span>mi_reserve_huge_os_pages_interleave()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mi_reserve_huge_os_pages_interleave </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>pages</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>numa_nodes</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>timeout_msecs</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reserve <em>pages</em> of huge OS pages (1GiB) evenly divided over <em>numa_nodes</em> nodes, but stops after at most <code>timeout_msecs</code> seconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pages</td><td>The number of 1GiB pages to reserve. </td></tr>
<tr><td class="paramname">numa_nodes</td><td>The number of nodes do evenly divide the pages over, or 0 for using the actual number of NUMA nodes. </td></tr>
<tr><td class="paramname">timeout_msecs</td><td>Maximum number of milli-seconds to try reserving, or 0 for no timeout. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, <em>ENOMEM</em> if running out of memory, or <em>ETIMEDOUT</em> if timed out.</dd></dl>
<p>The reserved memory is used by mimalloc to satisfy allocations. May quit before <em>timeout_msecs</em> are expired if it estimates it will take more than 1.5 times <em>timeout_msecs</em>. The time limit is needed because on some operating systems it can take a long time to reserve contiguous memory if the physical memory is fragmented. </p>
</div>
</div>
<a id="ga00ec3324b6b2591c7fe3677baa30a767" name="ga00ec3324b6b2591c7fe3677baa30a767"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga00ec3324b6b2591c7fe3677baa30a767">◆ </a></span>mi_reserve_os_memory()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mi_reserve_os_memory </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>commit</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>allow_large</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reserve OS memory for use by mimalloc. </p>
<p>Reserved areas are used before allocating from the OS again. By reserving a large area upfront, allocation can be more efficient, and can be better managed on systems without <code>mmap</code>/<code>VirtualAlloc</code> (like WASM for example). </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">size</td><td>The size to reserve. </td></tr>
<tr><td class="paramname">commit</td><td>Commit the memory upfront. </td></tr>
<tr><td class="paramname">allow_large</td><td>Allow large OS pages (2MiB) to be used? </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><em>0</em> if successful, and an error code otherwise (e.g. <code>ENOMEM</code>). </dd></dl>
</div>
</div>
<a id="ga32f519797fd9a81acb4f52d36e6d751b" name="ga32f519797fd9a81acb4f52d36e6d751b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga32f519797fd9a81acb4f52d36e6d751b">◆ </a></span>mi_reserve_os_memory_ex()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mi_reserve_os_memory_ex </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>commit</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>allow_large</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>exclusive</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="#ga99fe38650d0b02e0e0f89ee024db91d3">mi_arena_id_t</a> *</td> <td class="paramname"><span class="paramname"><em>arena_id</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reserve OS memory to be managed in an arena. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">size</td><td>Size the reserve. </td></tr>
<tr><td class="paramname">commit</td><td>Should the memory be initially committed? </td></tr>
<tr><td class="paramname">allow_large</td><td>Allow the use of large OS pages? </td></tr>
<tr><td class="paramname">exclusive</td><td>Is the returned arena exclusive? </td></tr>
<tr><td class="paramname">arena_id</td><td>The new arena identifier. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Zero on success, an error code otherwise. </dd></dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.11.0 </li>
</ul>
</div>
</body>
</html>