<trclass="memdesc:ga1ea64283508718d9d645c38efc2f4305"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Maximum size allowed for small allocations in <aclass="el"href="group__extended.html#ga7136c2e55cb22c98ecf95d08d6debb99"title="Allocate a small object.">mi_malloc_small</a> and <aclass="el"href="group__extended.html#ga220f29f40a44404b0061c15bc1c31152"title="Allocate a zero initialized small object.">mi_zalloc_small</a> (usually <code>128*sizeof(void*)</code> (= 1KB on 64-bit systems)) <ahref="group__extended.html#ga1ea64283508718d9d645c38efc2f4305">More...</a><br/></td></tr>
<trclass="memitem:ga299dae78d25ce112e384a98b7309c5be"><tdclass="memItemLeft"align="right"valign="top">typedef void() </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__extended.html#ga299dae78d25ce112e384a98b7309c5be">mi_deferred_free_fun</a>(bool force, unsigned long long heartbeat, void *arg)</td></tr>
<trclass="memdesc:gad823d23444a4b77a40f66bf075a98a0c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Type of output functions. <ahref="group__extended.html#gad823d23444a4b77a40f66bf075a98a0c">More...</a><br/></td></tr>
<trclass="memdesc:ga7136c2e55cb22c98ecf95d08d6debb99"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Allocate a small object. <ahref="group__extended.html#ga7136c2e55cb22c98ecf95d08d6debb99">More...</a><br/></td></tr>
<trclass="memdesc:ga220f29f40a44404b0061c15bc1c31152"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Allocate a zero initialized small object. <ahref="group__extended.html#ga220f29f40a44404b0061c15bc1c31152">More...</a><br/></td></tr>
<trclass="memdesc:ga089c859d9eddc5f9b4bd946cd53cebee"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return the available bytes in a memory block. <ahref="group__extended.html#ga089c859d9eddc5f9b4bd946cd53cebee">More...</a><br/></td></tr>
<trclass="memdesc:gac057927cd06c854b45fe7847e921bd47"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return the used allocation size. <ahref="group__extended.html#gac057927cd06c854b45fe7847e921bd47">More...</a><br/></td></tr>
<trclass="memdesc:ga537f13b299ddf801e49a5a94fde02c79"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print the main statistics. <ahref="group__extended.html#ga537f13b299ddf801e49a5a94fde02c79">More...</a><br/></td></tr>
<trclass="memdesc:ga854b1de8cb067c7316286c28b2fcd3d1"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Merge thread local statistics with the main statistics and reset. <ahref="group__extended.html#ga854b1de8cb067c7316286c28b2fcd3d1">More...</a><br/></td></tr>
<trclass="memdesc:gaf8e73efc2cbca9ebfdfb166983a04c17"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initialize mimalloc on a thread. <ahref="group__extended.html#gaf8e73efc2cbca9ebfdfb166983a04c17">More...</a><br/></td></tr>
<trclass="memdesc:ga0ae4581e85453456a0d658b2b98bf7bf"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Uninitialize mimalloc on a thread. <ahref="group__extended.html#ga0ae4581e85453456a0d658b2b98bf7bf">More...</a><br/></td></tr>
<trclass="memdesc:gab1dac8476c46cb9eecab767eb40c1525"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print out heap statistics for this thread. <ahref="group__extended.html#gab1dac8476c46cb9eecab767eb40c1525">More...</a><br/></td></tr>
<trclass="memdesc:gae5b17ff027cd2150b43a33040250cf3f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register an output function. <ahref="group__extended.html#gae5b17ff027cd2150b43a33040250cf3f">More...</a><br/></td></tr>
<trclass="memdesc:ga5f071b10d4df1c3658e04e7fd67a94e6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Is a pointer part of our heap? <ahref="group__extended.html#ga5f071b10d4df1c3658e04e7fd67a94e6">More...</a><br/></td></tr>
<trclass="memdesc:ga00ec3324b6b2591c7fe3677baa30a767"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Reserve OS memory for use by mimalloc. <ahref="group__extended.html#ga00ec3324b6b2591c7fe3677baa30a767">More...</a><br/></td></tr>
<trclass="memdesc:ga4c6486a1fdcd7a423b5f25fe4be8e0cf"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Manage a particular memory area for use by mimalloc. <ahref="group__extended.html#ga4c6486a1fdcd7a423b5f25fe4be8e0cf">More...</a><br/></td></tr>
<trclass="memdesc:ga3132f521fb756fc0e8ec0b74fb58df50"><tdclass="mdescLeft"> </td><tdclass="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. <ahref="group__extended.html#ga3132f521fb756fc0e8ec0b74fb58df50">More...</a><br/></td></tr>
<trclass="memdesc:ga7795a13d20087447281858d2c771cca1"><tdclass="mdescLeft"> </td><tdclass="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. <ahref="group__extended.html#ga7795a13d20087447281858d2c771cca1">More...</a><br/></td></tr>
<trclass="memdesc:gaad25050b19f30cd79397b227e0157a3f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Is the C runtime <em>malloc</em> API redirected? <ahref="group__extended.html#gaad25050b19f30cd79397b227e0157a3f">More...</a><br/></td></tr>
<trclass="memdesc:ga7d862c2affd5790381da14eb102a364d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return process information (time and memory usage). <ahref="group__extended.html#ga7d862c2affd5790381da14eb102a364d">More...</a><br/></td></tr>
<p>Maximum size allowed for small allocations in <aclass="el"href="group__extended.html#ga7136c2e55cb22c98ecf95d08d6debb99"title="Allocate a small object.">mi_malloc_small</a> and <aclass="el"href="group__extended.html#ga220f29f40a44404b0061c15bc1c31152"title="Allocate a zero initialized small object.">mi_zalloc_small</a> (usually <code>128*sizeof(void*)</code> (= 1KB on 64-bit systems)) </p>
<tr><tdclass="paramname">err</td><td>Error code (see <aclass="el"href="group__extended.html#gaa1d55e0e894be240827e5d87ec3a1f45"title="Register an error callback function.">mi_register_error()</a> for a complete list). </td></tr>
<tr><tdclass="paramname">arg</td><td>Argument that was passed at registration to hold extra state.</td></tr>
</table>
</dd>
</dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__extended.html#gaa1d55e0e894be240827e5d87ec3a1f45"title="Register an error callback function.">mi_register_error()</a></dd></dl>
<tr><tdclass="paramname">force</td><td>If <em>true</em>, aggressively return memory to the OS (can be expensive!)</td></tr>
</table>
</dd>
</dl>
<p>Regular code should not have to call this function. It can be beneficial in very narrow circumstances; in particular, when a long running thread allocates a lot of blocks that are freed by other threads it may improve resource usage by calling this every once in a while. </p>
<tr><tdclass="paramname">size</td><td>The minimal required size in bytes. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>the size <code>n</code> that will be allocated, where <code>n >= size</code>.</dd></dl>
<p>Generally, <code>mi_usable_size(mi_malloc(size)) == mi_good_size(size)</code>. This can be used to reduce internal wasted space when allocating buffers for example.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__extended.html#ga089c859d9eddc5f9b4bd946cd53cebee"title="Return the available bytes in a memory block.">mi_usable_size()</a></dd></dl>
<tr><tdclass="paramname">size</td><td>The size in bytes, can be at most <aclass="el"href="group__extended.html#ga1ea64283508718d9d645c38efc2f4305"title="Maximum size allowed for small allocations in mi_malloc_small and mi_zalloc_small (usually 128*sizeof...">MI_SMALL_SIZE_MAX</a>. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>a pointer to newly allocated memory of at least <em>size</em> bytes, or <em>NULL</em> if out of memory. This function is meant for use in run-time systems for best performance and does not check if <em>size</em> was indeed small – use with care! </dd></dl>
<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><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">start</td><td>Start of the memory area </td></tr>
<tr><tdclass="paramname">size</td><td>The size of the memory area. </td></tr>
<tr><tdclass="paramname">commit</td><td>Is the area already committed? </td></tr>
<tr><tdclass="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><tdclass="paramname">is_zero</td><td>Does the area consists of zero's? </td></tr>
<tr><tdclass="paramname">numa_node</td><td>Possible associated numa node or <code>-1</code>. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd><em>true</em> if successful, and <em>false</em> on error. </dd></dl>
<tr><tdclass="paramname">system_msecs</td><td>Optional. System time in milli-seconds. </td></tr>
<tr><tdclass="paramname">current_rss</td><td>Optional. Current working set size (touched pages). </td></tr>
<tr><tdclass="paramname">peak_rss</td><td>Optional. Peak working set size (touched pages). </td></tr>
<tr><tdclass="paramname">current_commit</td><td>Optional. Current committed memory (backed by the page file). </td></tr>
<tr><tdclass="paramname">peak_commit</td><td>Optional. Peak committed memory (backed by the page file). </td></tr>
<tr><tdclass="paramname">page_faults</td><td>Optional. Count of hard page faults.</td></tr>
</table>
</dd>
</dl>
<p>The <em>current_rss</em> is precise on Windows and MacOSX; other systems estimate this using <em>current_commit</em>. The <em>commit</em> is precise on Windows but estimated on other systems as the amount of read/write accessible memory reserved by mimalloc. </p>
<p>Some runtime systems use deferred free-ing, for example when using reference counting to limit the worst case free time. Such systems can register (re-entrant) deferred free function to free more memory on demand. When the <em>force</em> parameter is <em>true</em> all possible memory should be freed. The per-thread <em>heartbeat</em> parameter is monotonically increasing and guaranteed to be deterministic if the program allocates deterministically. The <em>deferred_free</em> function is guaranteed to be called deterministically after some number of allocations (regardless of freeing or available free memory). At most one <em>deferred_free</em> function can be active. </p>
<tr><tdclass="paramname">errfun</td><td>The error function that is called on an error (use <em>NULL</em> for default) </td></tr>
<tr><tdclass="paramname">arg</td><td>Extra argument that will be passed on to the error function.</td></tr>
</table>
</dd>
</dl>
<p>The <em>errfun</em> function is called on an error in mimalloc after emitting an error message (through the output function). It as always legal to just return from the <em>errfun</em> function in which case allocation functions generally return <em>NULL</em> or ignore the condition. The default function only calls abort() when compiled in secure mode with an <em>EFAULT</em> error. The possible error codes are:</p><ul>
<li><em>EAGAIN:</em> Double free was detected (only in debug and secure mode).</li>
<li><em>EFAULT:</em> Corrupted free list or meta-data was detected (only in debug and secure mode).</li>
<li><em>ENOMEM:</em> Not enough memory available to satisfy the request.</li>
<li><em>EOVERFLOW:</em> Too large a request, for example in <aclass="el"href="group__malloc.html#ga97fedb4f7107c592fd7f0f0a8949a57d"title="Allocate zero-initialized count elements of size bytes.">mi_calloc()</a>, the <em>count</em> and <em>size</em> parameters are too large.</li>
<li><em>EINVAL:</em> Trying to free or re-allocate an invalid pointer. </li>
<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>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">pages</td><td>The number of 1GiB pages to reserve. </td></tr>
<tr><tdclass="paramname">numa_node</td><td>The NUMA node where the memory is reserved (start at 0). </td></tr>
<tr><tdclass="paramname">timeout_msecs</td><td>Maximum number of milli-seconds to try reserving, or 0 for no timeout. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>0 if successfull, <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>
<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>
<tr><tdclass="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><tdclass="paramname">timeout_msecs</td><td>Maximum number of milli-seconds to try reserving, or 0 for no timeout. </td></tr>
<dlclass="section return"><dt>Returns</dt><dd>0 if successfull, <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>
<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><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">size</td><td>The size to reserve. </td></tr>
<tr><tdclass="paramname">commit</td><td>Commit the memory upfront. </td></tr>
<tr><tdclass="paramname">allow_large</td><td>Allow large OS pages (2MiB) to be used? </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd><em>0</em> if successful, and an error code otherwise (e.g. <code>ENOMEM</code>). </dd></dl>
<p>Should not be used as on most systems (pthreads, windows) this is done automatically. Ensures that any memory that is not freed yet (but will be freed by other threads in the future) is properly handled. </p>
<p>Return the available bytes in a memory block. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">p</td><td>Pointer to previously allocated memory (or <em>NULL</em>) </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Returns the available bytes in the memory block, or 0 if <em>p</em> was <em>NULL</em>.</dd></dl>
<p>The returned size can be used to call <em>mi_expand</em> successfully. The returned size is always at least equal to the allocated size of <em>p</em>, and, in the current design, should be less than 16.7% more.</p>
<tr><tdclass="paramname">size</td><td>The size in bytes, can be at most <aclass="el"href="group__extended.html#ga1ea64283508718d9d645c38efc2f4305"title="Maximum size allowed for small allocations in mi_malloc_small and mi_zalloc_small (usually 128*sizeof...">MI_SMALL_SIZE_MAX</a>. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>a pointer to newly allocated zero-initialized memory of at least <em>size</em> bytes, or <em>NULL</em> if out of memory. This function is meant for use in run-time systems for best performance and does not check if <em>size</em> was indeed small – use with care! </dd></dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.9.1 </li>