<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: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:ga9398517f01a1ec971244aa0db084ea46"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initialize mimalloc on a thread. <ahref="#ga9398517f01a1ec971244aa0db084ea46">More...</a><br/></td></tr>
<trclass="memdesc:gac0f4849256aaf677f334690952c6ebbd"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Uninitialize mimalloc on a thread. <ahref="#gac0f4849256aaf677f334690952c6ebbd">More...</a><br/></td></tr>
<trclass="memdesc:ga490826cbd7c494acc9fe69be23f018ac"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print out heap statistics for this thread. <ahref="#ga490826cbd7c494acc9fe69be23f018ac">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>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! -->