<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:ga22213691c3ce5ab4d91b24aff1023529"><tdclass="memItemLeft"align="right"valign="top">typedef void() </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__extended.html#ga22213691c3ce5ab4d91b24aff1023529">mi_deferred_free_fun</a>(bool force, unsigned long long heartbeat)</td></tr>
<trclass="memdesc:ga22213691c3ce5ab4d91b24aff1023529"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Type of deferred free functions. <ahref="#ga22213691c3ce5ab4d91b24aff1023529">More...</a><br/></td></tr>
<trclass="memdesc:ga2bed6d40b74591a67f81daea4b4a246f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Type of output functions. <ahref="#ga2bed6d40b74591a67f81daea4b4a246f">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:ga8ca07ccff283956d71f48272f4fd5c01"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print the main statistics. <ahref="#ga8ca07ccff283956d71f48272f4fd5c01">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:ga489670a15d1a257ab4639e645ee4612a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print out heap statistics for this thread. <ahref="#ga489670a15d1a257ab4639e645ee4612a">More...</a><br/></td></tr>
<trclass="memdesc:ga84a0c8b401e42eb5b1bce156852f44c5"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Register an output function. <ahref="#ga84a0c8b401e42eb5b1bce156852f44c5">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:ga2664f36a2dd557741c429cb799f04641"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Reserve <em>pages</em> of huge OS pages (1GiB) but stops after at most <code>max_secs</code> seconds. <ahref="#ga2664f36a2dd557741c429cb799f04641">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>
<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">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>
<tr><tdclass="paramname">deferred_free</td><td>Address of a deferred free-ing function or <em>NULL</em> to unregister.</td></tr>
</table>
</dd>
</dl>
<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>
<p>Reserve <em>pages</em> of huge OS pages (1GiB) but stops after at most <code>max_secs</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">max_secs</td><td>Maximum number of seconds to try reserving. </td></tr>
<tr><tdclass="paramname">pages_reserved</td><td>If not <em>NULL</em>, it is set to the actual number of pages that were reserved. </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>max_secs</em> are expired if it estimates it will take more than 1.5 times <em>max_secs</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! -->