mimalloc/docs/index.html

143 lines
9.1 KiB
HTML
Raw Permalink Normal View History

2019-07-08 17:15:34 -07:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2019-06-22 10:28:41 -07:00
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
2021-12-18 16:36:37 -08:00
<meta name="generator" content="Doxygen 1.9.1"/>
2019-06-22 10:28:41 -07:00
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>mi-malloc: Main Page</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>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.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:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(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 style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="mimalloc-logo.svg"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">mi-malloc
2021-12-18 16:36:37 -08:00
&#160;<span id="projectnumber">1.7/2.0</span>
2019-06-22 10:28:41 -07:00
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
2021-12-18 16:36:37 -08:00
<img id="MSearchSelect" src="search/mag_sel.svg"
2019-06-22 10:28:41 -07:00
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
2019-06-22 10:28:41 -07:00
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
2021-12-18 16:36:37 -08:00
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
2019-06-22 10:28:41 -07:00
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
2021-12-18 16:36:37 -08:00
<!-- Generated by Doxygen 1.9.1 -->
2019-06-22 10:28:41 -07:00
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
2021-12-18 16:36:37 -08:00
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
2019-06-22 10:28:41 -07:00
/* @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;"
2019-06-22 10:28:41 -07:00
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
2021-12-18 16:36:37 -08:00
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
2019-06-22 10:28:41 -07:00
/* @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">
<iframe src="javascript:void(0)" frameborder="0"
2019-06-22 10:28:41 -07:00
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
2019-07-08 17:15:34 -07:00
<div class="PageDoc"><div class="header">
2019-06-22 10:28:41 -07:00
<div class="headertitle">
<div class="title">mi-malloc Documentation</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This is the API documentation of the <a href="https://github.com/microsoft/mimalloc">mimalloc</a> allocator (pronounced "me-malloc") &ndash; a general purpose allocator with excellent <a href="bench.html">performance</a> characteristics. Initially developed by Daan Leijen for the run-time systems of the <a href="https://github.com/koka-lang/koka">Koka</a> and <a href="https://github.com/leanprover/lean">Lean</a> languages.</p>
2021-12-18 16:36:37 -08:00
<p>It is a drop-in replacement for <code>malloc</code> and can be used in other programs without code changes, for example, on Unix you can use it as: </p><div class="fragment"><div class="line">&gt; LD_PRELOAD=/usr/bin/libmimalloc.so myprogram</div>
</div><!-- fragment --><p>Notable aspects of the design include:</p>
2019-06-22 10:28:41 -07:00
<ul>
2020-09-24 10:33:33 -07:00
<li><b>small and consistent</b>: the library is about 8k LOC using simple and consistent data structures. This makes it very suitable to integrate and adapt in other projects. For runtime systems it provides hooks for a monotonic <em>heartbeat</em> and deferred freeing (for bounded worst-case times with reference counting).</li>
<li><b>free list sharding</b>: instead of one big free list (per size class) we have many smaller lists per "mimalloc page" which reduces fragmentation and increases locality &ndash; things that are allocated close in time get allocated close in memory. (A mimalloc page contains blocks of one size class and is usually 64KiB on a 64-bit system).</li>
<li><b>free list multi-sharding</b>: the big idea! Not only do we shard the free list per mimalloc page, but for each page we have multiple free lists. In particular, there is one list for thread-local <code>free</code> operations, and another one for concurrent <code>free</code> operations. Free-ing from another thread can now be a single CAS without needing sophisticated coordination between threads. Since there will be thousands of separate free lists, contention is naturally distributed over the heap, and the chance of contending on a single location will be low &ndash; this is quite similar to randomized algorithms like skip lists where adding a random oracle removes the need for a more complex algorithm.</li>
2019-06-22 10:28:41 -07:00
<li><b>eager page reset</b>: when a "page" becomes empty (with increased chance due to free list sharding) the memory is marked to the OS as unused ("reset" or "purged") reducing (real) memory pressure and fragmentation, especially in long running programs.</li>
2021-12-18 16:36:37 -08:00
<li><b>secure</b>: <em>mimalloc</em> can be build in secure mode, adding guard pages, randomized allocation, encrypted free lists, etc. to protect against various heap vulnerabilities. The performance penalty is only around 5% on average over our benchmarks.</li>
2019-06-22 10:28:41 -07:00
<li><b>first-class heaps</b>: efficiently create and use multiple heaps to allocate across different regions. A heap can be destroyed at once instead of deallocating each object separately.</li>
2019-09-11 20:48:41 -07:00
<li><b>bounded</b>: it does not suffer from <em>blowup</em> [1], has bounded worst-case allocation times (<em>wcat</em>), bounded space overhead (~0.2% meta-data, with at most 12.5% waste in allocation sizes), and has no internal points of contention using only atomic operations.</li>
2020-09-24 10:33:33 -07:00
<li><b>fast</b>: In our benchmarks (see <a href="#performance">below</a>), <em>mimalloc</em> outperforms all other leading allocators (<em>jemalloc</em>, <em>tcmalloc</em>, <em>Hoard</em>, etc), and usually uses less memory (up to 25% more in the worst case). A nice property is that it does consistently well over a wide range of benchmarks.</li>
2019-06-22 10:28:41 -07:00
</ul>
2019-09-11 20:48:41 -07:00
<p>You can read more on the design of <em>mimalloc</em> in the <a href="https://www.microsoft.com/en-us/research/publication/mimalloc-free-list-sharding-in-action">technical report</a> which also has detailed benchmark results.</p>
2019-06-22 10:28:41 -07:00
<p>Further information:</p>
<ul>
<li><a class="el" href="build.html">Building</a></li>
<li><a class="el" href="using.html">Using the library</a></li>
2019-09-11 20:48:41 -07:00
<li><a class="el" href="environment.html">Environment Options</a></li>
2019-06-22 10:28:41 -07:00
<li><a class="el" href="overrides.html">Overriding Malloc</a></li>
<li><a class="el" href="bench.html">Performance</a></li>
<li><a class="el" href="group__malloc.html">Basic Allocation</a></li>
<li><a class="el" href="group__extended.html">Extended Functions</a></li>
<li><a class="el" href="group__aligned.html">Aligned Allocation</a></li>
<li><a class="el" href="group__heap.html">Heap Allocation</a></li>
<li><a class="el" href="group__typed.html">Typed Macros</a></li>
<li><a class="el" href="group__analysis.html">Heap Introspection</a></li>
2020-04-20 12:00:39 -07:00
<li><a class="el" href="group__options.html">Runtime Options</a></li>
<li><a class="el" href="group__posix.html">Posix</a></li>
<li><a class="el" href="group__cpp.html">C++ wrappers</a> </li>
2019-06-22 10:28:41 -07:00
</ul>
2019-07-08 17:15:34 -07:00
</div></div><!-- PageDoc -->
</div><!-- contents -->
2019-06-22 10:28:41 -07:00
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
2021-12-18 16:36:37 -08:00
<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.9.1 </li>
2019-06-22 10:28:41 -07:00
</ul>
</div>
</body>
</html>