<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="#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:ga299dae78d25ce112e384a98b7309c5be"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Type of deferred free functions. <ahref="#ga299dae78d25ce112e384a98b7309c5be">More...</a><br/></td></tr>
<trclass="memdesc:gad823d23444a4b77a40f66bf075a98a0c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Type of output functions. <ahref="#gad823d23444a4b77a40f66bf075a98a0c">More...</a><br/></td></tr>
<trclass="memdesc:ga7136c2e55cb22c98ecf95d08d6debb99"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Allocate a small object. <ahref="#ga7136c2e55cb22c98ecf95d08d6debb99">More...</a><br/></td></tr>
<trclass="memdesc:ga220f29f40a44404b0061c15bc1c31152"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Allocate a zero initialized small object. <ahref="#ga220f29f40a44404b0061c15bc1c31152">More...</a><br/></td></tr>
<trclass="memdesc:ga089c859d9eddc5f9b4bd946cd53cebee"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return the available bytes in a memory block. <ahref="#ga089c859d9eddc5f9b4bd946cd53cebee">More...</a><br/></td></tr>
<trclass="memdesc:gac057927cd06c854b45fe7847e921bd47"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return the used allocation size. <ahref="#gac057927cd06c854b45fe7847e921bd47">More...</a><br/></td></tr>
<trclass="memdesc:ga537f13b299ddf801e49a5a94fde02c79"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print the main statistics. <ahref="#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="#ga854b1de8cb067c7316286c28b2fcd3d1">More...</a><br/></td></tr>
<trclass="memdesc:gaf8e73efc2cbca9ebfdfb166983a04c17"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initialize mimalloc on a thread. <ahref="#gaf8e73efc2cbca9ebfdfb166983a04c17">More...</a><br/></td></tr>
<trclass="memdesc:ga0ae4581e85453456a0d658b2b98bf7bf"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Uninitialize mimalloc on a thread. <ahref="#ga0ae4581e85453456a0d658b2b98bf7bf">More...</a><br/></td></tr>
<trclass="memdesc:gab1dac8476c46cb9eecab767eb40c1525"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print out heap statistics for this thread. <ahref="#gab1dac8476c46cb9eecab767eb40c1525">More...</a><br/></td></tr>
<trclass="memdesc:gae5b17ff027cd2150b43a33040250cf3f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register an output function. <ahref="#gae5b17ff027cd2150b43a33040250cf3f">More...</a><br/></td></tr>
<trclass="memdesc:ga5f071b10d4df1c3658e04e7fd67a94e6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Is a pointer part of our heap? <ahref="#ga5f071b10d4df1c3658e04e7fd67a94e6">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="#ga3132f521fb756fc0e8ec0b74fb58df50">More...</a><br/></td></tr>
<trclass="memitem:ga7795a13d20087447281858d2c771cca1"><tdclass="memItemLeft"align="right"valign="top">int </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__extended.html#ga7795a13d20087447281858d2c771cca1">mi_reserve_huge_os_pages_at</a> (size_t pages, int numa_node, size_t timeout_msecs)</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="#ga7795a13d20087447281858d2c771cca1">More...</a><br/></td></tr>
<trclass="memdesc:gaad25050b19f30cd79397b227e0157a3f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Is the C runtime <em>malloc</em> API redirected? <ahref="#gaad25050b19f30cd79397b227e0157a3f">More...</a><br/></td></tr>
<trclass="memdesc:ga9144506d5ffa8cc03547867bd15e1032"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Return process information (time and memory usage). <ahref="#ga9144506d5ffa8cc03547867bd15e1032">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>Return process information (time and memory usage). </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">user_msecs</td><td>Optional. User time in milli-seconds. </td></tr>
<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>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! -->