We tested mimalloc against many other top allocators over a wide range of benchmarks, ranging from various real world programs to synthetic benchmarks that see how the allocator behaves under more extreme circumstances.
-
In our benchmarks, mimalloc always outperforms all other leading allocators (jemalloc, tcmalloc, Hoard, etc) (Apr 2019), and usually uses less memory (up to 25% more in the worst case). A nice property is that it does consistently well over the wide range of benchmarks.
+
In our benchmarks, mimalloc always outperforms all other leading allocators (jemalloc, tcmalloc, Hoard, etc) (Jan 2021), and usually uses less memory (up to 25% more in the worst case). A nice property is that it does consistently well over the wide range of benchmarks.
See the Performance section in the mimalloc repository for benchmark results, or the the technical report for detailed benchmark results.
Open ide/vs2019/mimalloc.sln in Visual Studio 2019 and build (or ide/vs2017/mimalloc.sln). The mimalloc project builds a static library (in out/msvc-x64), while the mimalloc-override project builds a DLL for overriding malloc in the entire program.
diff --git a/docs/doxygen.css b/docs/doxygen.css
index 723847168..f090ef799 100644
--- a/docs/doxygen.css
+++ b/docs/doxygen.css
@@ -1,4 +1,4 @@
-/* The standard CSS for doxygen 1.8.15 */
+/* The standard CSS for doxygen 1.9.1 */
body, table, div, p, dl {
font: 400 14px/22px Roboto,sans-serif;
@@ -53,17 +53,24 @@ dt {
font-weight: bold;
}
-div.multicol {
+ul.multicol {
-moz-column-gap: 1em;
-webkit-column-gap: 1em;
+ column-gap: 1em;
-moz-column-count: 3;
-webkit-column-count: 3;
+ column-count: 3;
}
p.startli, p.startdd {
margin-top: 2px;
}
+th p.starttd, th p.intertd, th p.endtd {
+ font-size: 100%;
+ font-weight: 700;
+}
+
p.starttd {
margin-top: 0px;
}
@@ -96,30 +103,96 @@ caption {
}
span.legend {
- font-size: 70%;
- text-align: center;
+ font-size: 70%;
+ text-align: center;
}
h3.version {
- font-size: 90%;
- text-align: center;
+ font-size: 90%;
+ text-align: center;
}
-div.qindex, div.navtab{
- background-color: #D6D9D9;
- border: 1px solid #636C6D;
- text-align: center;
+div.navtab {
+ border-right: 1px solid #636C6D;
+ padding-right: 15px;
+ text-align: right;
+ line-height: 110%;
+}
+
+div.navtab table {
+ border-spacing: 0;
+}
+
+td.navtab {
+ padding-right: 6px;
+ padding-left: 6px;
+}
+td.navtabHL {
+ background-image: url('tab_a.png');
+ background-repeat:repeat-x;
+ padding-right: 6px;
+ padding-left: 6px;
+}
+
+td.navtabHL a, td.navtabHL a:visited {
+ color: #fff;
+ text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
+}
+
+a.navtab {
+ font-weight: bold;
}
-div.qindex, div.navpath {
+div.qindex{
+ text-align: center;
width: 100%;
line-height: 140%;
+ font-size: 130%;
+ color: #A0A0A0;
}
-div.navtab {
- margin-right: 15px;
+dt.alphachar{
+ font-size: 180%;
+ font-weight: bold;
+}
+
+.alphachar a{
+ color: black;
+}
+
+.alphachar a:hover, .alphachar a:visited{
+ text-decoration: none;
+}
+
+.classindex dl {
+ padding: 25px;
+ column-count:1
+}
+
+.classindex dd {
+ display:inline-block;
+ margin-left: 50px;
+ width: 90%;
+ line-height: 1.15em;
+}
+
+.classindex dl.odd {
+ background-color: #F0F1F1;
+}
+
+@media(min-width: 1120px) {
+ .classindex dl {
+ column-count:2
+ }
+}
+
+@media(min-width: 1320px) {
+ .classindex dl {
+ column-count:3
+ }
}
+
/* @group Link Styling */
a {
@@ -136,17 +209,6 @@ a:hover {
text-decoration: underline;
}
-a.qindex {
- font-weight: bold;
-}
-
-a.qindexHL {
- font-weight: bold;
- background-color: #5B6364;
- color: #FFFFFF;
- border: 1px double #464C4D;
-}
-
.contents a.qindexHL:visited {
color: #FFFFFF;
}
@@ -533,7 +595,7 @@ table.memberdecls {
white-space: nowrap;
}
-.memItemRight {
+.memItemRight, .memTemplItemRight {
width: 100%;
}
@@ -701,7 +763,7 @@ dl.reflist dd {
padding-left: 0px;
}
-.params .paramname, .retval .paramname, .tparams .paramname {
+.params .paramname, .retval .paramname, .tparams .paramname, .exception .paramname {
font-weight: bold;
vertical-align: top;
}
@@ -1351,10 +1413,12 @@ dl.citelist dt {
font-weight:bold;
margin-right:10px;
padding:5px;
+ text-align:right;
+ width:52px;
}
dl.citelist dd {
- margin:2px 0;
+ margin:2px 0 2px 72px;
padding:5px 0;
}
@@ -1417,6 +1481,12 @@ div.toc li.level4 {
margin-left: 45px;
}
+span.emoji {
+ /* font family used at the site: https://unicode.org/emoji/charts/full-emoji-list.html
+ * font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", Times, Symbola, Aegyptus, Code2000, Code2001, Code2002, Musica, serif, LastResort;
+ */
+}
+
.PageDocRTL-title div.toc li.level1 {
margin-left: 0 !important;
margin-right: 0;
@@ -1654,47 +1724,6 @@ tr.heading h2 {
/* @group Markdown */
-/*
-table.markdownTable {
- border-collapse:collapse;
- margin-top: 4px;
- margin-bottom: 4px;
-}
-
-table.markdownTable td, table.markdownTable th {
- border: 1px solid #060606;
- padding: 3px 7px 2px;
-}
-
-table.markdownTableHead tr {
-}
-
-table.markdownTableBodyLeft td, table.markdownTable th {
- border: 1px solid #060606;
- padding: 3px 7px 2px;
-}
-
-th.markdownTableHeadLeft th.markdownTableHeadRight th.markdownTableHeadCenter th.markdownTableHeadNone {
- background-color: #0B0C0C;
- color: #FFFFFF;
- font-size: 110%;
- padding-bottom: 4px;
- padding-top: 5px;
-}
-
-th.markdownTableHeadLeft {
- text-align: left
-}
-
-th.markdownTableHeadRight {
- text-align: right
-}
-
-th.markdownTableHeadCenter {
- text-align: center
-}
-*/
-
table.markdownTable {
border-collapse:collapse;
margin-top: 4px;
diff --git a/docs/dynsections.js b/docs/dynsections.js
index ea0a7b39a..3174bd7be 100644
--- a/docs/dynsections.js
+++ b/docs/dynsections.js
@@ -1,25 +1,26 @@
/*
- @licstart The following is the entire license notice for the
- JavaScript code in this file.
+ @licstart The following is the entire license notice for the JavaScript code in this file.
- Copyright (C) 1997-2017 by Dimitri van Heesch
+ The MIT License (MIT)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ Copyright (C) 1997-2020 by Dimitri van Heesch
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
- @licend The above is the entire license notice
- for the JavaScript code in this file
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ @licend The above is the entire license notice for the JavaScript code in this file
*/
function toggleVisibility(linkObj)
{
diff --git a/docs/environment.html b/docs/environment.html
index 87d67e4a0..f571f95f8 100644
--- a/docs/environment.html
+++ b/docs/environment.html
@@ -3,7 +3,7 @@
-
+
mi-malloc: Environment Options
@@ -13,10 +13,6 @@
-
@@ -37,12 +33,12 @@
MIMALLOC_PAGE_RESET=0: by default, mimalloc will reset (or purge) OS pages when not in use to signal to the OS that the underlying physical memory can be reused. This can reduce memory fragmentation in long running (server) programs. By setting it to 0 no such page resets will be done which can improve performance for programs that are not long running. As an alternative, the MIMALLOC_RESET_DELAY=<msecs> can be set higher (100ms by default) to make the page reset occur less frequently instead of turning it off completely.
MIMALLOC_LARGE_OS_PAGES=1: use large OS pages (2MiB) when available; for some workloads this can significantly improve performance. Use MIMALLOC_VERBOSE to check if the large OS pages are enabled – usually one needs to explicitly allow large OS pages (as on Windows and Linux). However, sometimes the OS is very slow to reserve contiguous physical memory for large OS pages so use with care on systems that can have fragmented memory (for that reason, we generally recommend to use MIMALLOC_RESERVE_HUGE_OS_PAGES instead when possible).
MIMALLOC_RESERVE_HUGE_OS_PAGES=N: where N is the number of 1GiB huge OS pages. This reserves the huge pages at startup and sometimes this can give a large (latency) performance improvement on big workloads. Usually it is better to not use MIMALLOC_LARGE_OS_PAGES in combination with this setting. Just like large OS pages, use with care as reserving contiguous physical memory can take a long time when memory is fragmented (but reserving the huge pages is done at startup only once). Note that we usually need to explicitly enable huge OS pages (as on Windows and Linux)). With huge OS pages, it may be beneficial to set the setting MIMALLOC_EAGER_COMMIT_DELAY=N (N is 1 by default) to delay the initial N segments (of 4MiB) of a thread to not allocate in the huge OS pages; this prevents threads that are short lived and allocate just a little to take up space in the huge OS page area (which cannot be reset).
+
MIMALLOC_RESERVE_HUGE_OS_PAGES_AT=N: where N is the numa node. This reserves the huge pages at a specific numa node. (N is -1 by default to reserve huge pages evenly among the given number of numa nodes (or use the available ones as detected))
Use caution when using fork in combination with either large or huge OS pages: on a fork, the OS uses copy-on-write for all pages in the original process including the huge OS pages. When any memory is now written in that area, the OS will copy the entire 1GiB huge page (or 2MiB large page) which can cause the memory usage to grow in big increments.
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 mmap/VirtualAlloc (like WASM for example).
Parameters
+
+
size
The size to reserve.
+
commit
Commit the memory upfront.
+
allow_large
Allow large OS pages (2MiB) to be used?
+
+
+
+
Returns
0 if successful, and an error code otherwise (e.g. ENOMEM).
This is the API documentation of the mimalloc allocator (pronounced "me-malloc") – a general purpose allocator with excellent performance characteristics. Initially developed by Daan Leijen for the run-time systems of the Koka and Lean languages.
-
It is a drop-in replacement for malloc and can be used in other programs without code changes, for example, on Unix you can use it as:
> LD_PRELOAD=/usr/bin/libmimalloc.so myprogram
Notable aspects of the design include:
+
It is a drop-in replacement for malloc and can be used in other programs without code changes, for example, on Unix you can use it as:
> LD_PRELOAD=/usr/bin/libmimalloc.so myprogram
+
Notable aspects of the design include:
small and consistent: 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 heartbeat and deferred freeing (for bounded worst-case times with reference counting).
free list sharding: instead of one big free list (per size class) we have many smaller lists per "mimalloc page" which reduces fragmentation and increases locality – 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).
free list multi-sharding: 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 free operations, and another one for concurrent free 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 – this is quite similar to randomized algorithms like skip lists where adding a random oracle removes the need for a more complex algorithm.
eager page reset: 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.
-
secure: mimalloc 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 3% on average over our benchmarks.
+
secure: mimalloc 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.
first-class heaps: efficiently create and use multiple heaps to allocate across different regions. A heap can be destroyed at once instead of deallocating each object separately.
bounded: it does not suffer from blowup [1], has bounded worst-case allocation times (wcat), 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.
fast: In our benchmarks (see below), mimalloc outperforms all other leading allocators (jemalloc, tcmalloc, Hoard, 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.
diff --git a/docs/navtree.js b/docs/navtree.js
index 7ce293523..1e272d31d 100644
--- a/docs/navtree.js
+++ b/docs/navtree.js
@@ -1,25 +1,26 @@
/*
- @licstart The following is the entire license notice for the
- JavaScript code in this file.
+ @licstart The following is the entire license notice for the JavaScript code in this file.
- Copyright (C) 1997-2017 by Dimitri van Heesch
+ The MIT License (MIT)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ Copyright (C) 1997-2020 by Dimitri van Heesch
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
- @licend The above is the entire license notice
- for the JavaScript code in this file
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ @licend The above is the entire license notice for the JavaScript code in this file
*/
var navTreeSubIndices = new Array();
var arrowDown = '▼';
@@ -70,7 +71,6 @@ function localStorageSupported()
}
}
-
function storeLink(link)
{
if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
@@ -102,14 +102,6 @@ function getScript(scriptName,func,show)
script.type = 'text/javascript';
script.onload = func;
script.src = scriptName+'.js';
- if ($.browser.msie && $.browser.version<=8) {
- // script.onload does not work with older versions of IE
- script.onreadystatechange = function() {
- if (script.readyState=='complete' || script.readyState=='loaded') {
- func(); if (show) showRoot();
- }
- }
- }
head.appendChild(script);
}
@@ -153,6 +145,7 @@ function gotoAnchor(anchor,aname,updateLocation)
var pos, docContent = $('#doc-content');
var ancParent = $(anchor.parent());
if (ancParent.hasClass('memItemLeft') ||
+ ancParent.hasClass('memtitle') ||
ancParent.hasClass('fieldname') ||
ancParent.hasClass('fieldtype') ||
ancParent.is(':header'))
@@ -265,7 +258,7 @@ function showRoot()
(function (){ // retry until we can scroll to the selected item
try {
var navtree=$('#nav-tree');
- navtree.scrollTo('#selected',0,{offset:-windowHeight/2});
+ navtree.scrollTo('#selected',100,{offset:-windowHeight/2});
} catch (err) {
setTimeout(arguments.callee, 0);
}
@@ -284,12 +277,8 @@ function expandNode(o, node, imm, showRoot)
} else {
if (!node.childrenVisited) {
getNode(o, node);
- } if (imm || ($.browser.msie && $.browser.version>8)) {
- // somehow slideDown jumps to the start of tree for IE9 :-(
- $(node.getChildrenUL()).show();
- } else {
- $(node.getChildrenUL()).slideDown("fast");
}
+ $(node.getChildrenUL()).slideDown("fast");
node.plus_img.innerHTML = arrowDown;
node.expanded = true;
}
@@ -319,7 +308,6 @@ function highlightAnchor()
} else {
glowEffect(anchor.next(),1000); // normal member
}
- gotoAnchor(anchor,aname,false);
}
function selectAndHighlight(hash,n)
@@ -481,6 +469,18 @@ function toggleSyncButton(relpath)
}
}
+var loadTriggered = false;
+var readyTriggered = false;
+var loadObject,loadToRoot,loadUrl,loadRelPath;
+
+$(window).on('load',function(){
+ if (readyTriggered) { // ready first
+ navTo(loadObject,loadToRoot,loadUrl,loadRelPath);
+ showRoot();
+ }
+ loadTriggered=true;
+});
+
function initNavTree(toroot,relpath)
{
var o = new Object();
@@ -511,10 +511,16 @@ function initNavTree(toroot,relpath)
navSync.click(function(){ toggleSyncButton(relpath); });
}
- $(window).load(function(){
+ if (loadTriggered) { // load before ready
navTo(o,toroot,hashUrl(),relpath);
showRoot();
- });
+ } else { // ready before load
+ loadObject = o;
+ loadToRoot = toroot;
+ loadUrl = hashUrl();
+ loadRelPath = relpath;
+ readyTriggered=true;
+ }
$(window).bind('hashchange', function(){
if (window.location.hash && window.location.hash.length>1){
diff --git a/docs/navtreedata.js b/docs/navtreedata.js
index e6dc7bc0e..8dd5a5550 100644
--- a/docs/navtreedata.js
+++ b/docs/navtreedata.js
@@ -1,25 +1,26 @@
/*
-@ @licstart The following is the entire license notice for the
-JavaScript code in this file.
+ @licstart The following is the entire license notice for the JavaScript code in this file.
-Copyright (C) 1997-2017 by Dimitri van Heesch
+ The MIT License (MIT)
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ Copyright (C) 1997-2020 by Dimitri van Heesch
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
-@licend The above is the entire license notice
-for the JavaScript code in this file
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ @licend The above is the entire license notice for the JavaScript code in this file
*/
var NAVTREE =
[
diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js
index 4a1e93fa9..72181708b 100644
--- a/docs/navtreeindex0.js
+++ b/docs/navtreeindex0.js
@@ -8,14 +8,15 @@ var NAVTREEINDEX0 =
"functions.html":[6,2,0],
"functions_vars.html":[6,2,1],
"group__aligned.html":[5,2],
-"group__aligned.html#ga08647c4593f3b2eef24a919a73eba3a3":[5,2,1],
-"group__aligned.html#ga0cadbcf5b89a7b6fb171bc8df8734819":[5,2,6],
-"group__aligned.html#ga4028d1cf4aa4c87c880747044a8322ae":[5,2,4],
-"group__aligned.html#ga53dddb4724042a90315b94bc268fb4c9":[5,2,0],
-"group__aligned.html#ga5850da130c936bd77db039dcfbc8295d":[5,2,3],
-"group__aligned.html#ga5f8c2353766db522565e642fafd8a3f8":[5,2,7],
-"group__aligned.html#ga68930196751fa2cca9e1fd0d71bade56":[5,2,2],
-"group__aligned.html#gaf66a9ae6c6f08bd6be6fb6ea771faffb":[5,2,5],
+"group__aligned.html#ga08647c4593f3b2eef24a919a73eba3a3":[5,2,2],
+"group__aligned.html#ga0cadbcf5b89a7b6fb171bc8df8734819":[5,2,7],
+"group__aligned.html#ga4028d1cf4aa4c87c880747044a8322ae":[5,2,5],
+"group__aligned.html#ga53dddb4724042a90315b94bc268fb4c9":[5,2,1],
+"group__aligned.html#ga5850da130c936bd77db039dcfbc8295d":[5,2,4],
+"group__aligned.html#ga5f8c2353766db522565e642fafd8a3f8":[5,2,8],
+"group__aligned.html#ga68930196751fa2cca9e1fd0d71bade56":[5,2,3],
+"group__aligned.html#ga83c03016066b438f51a8095e9140be06":[5,2,0],
+"group__aligned.html#gaf66a9ae6c6f08bd6be6fb6ea771faffb":[5,2,6],
"group__analysis.html":[5,6],
"group__analysis.html#a332a6c14d736a99699d5453a1cb04b41":[5,6,0,0],
"group__analysis.html#ab47526df656d8837ec3e97f11b83f835":[5,6,0,2],
@@ -38,30 +39,32 @@ var NAVTREEINDEX0 =
"group__cpp.html#gaef2c2bdb4f70857902d3c8903ac095f3":[5,9,2],
"group__cpp.html#structmi__stl__allocator":[5,9,0],
"group__extended.html":[5,1],
-"group__extended.html#ga089c859d9eddc5f9b4bd946cd53cebee":[5,1,22],
-"group__extended.html#ga0ae4581e85453456a0d658b2b98bf7bf":[5,1,19],
+"group__extended.html#ga00ec3324b6b2591c7fe3677baa30a767":[5,1,16],
+"group__extended.html#ga089c859d9eddc5f9b4bd946cd53cebee":[5,1,24],
+"group__extended.html#ga0ae4581e85453456a0d658b2b98bf7bf":[5,1,21],
"group__extended.html#ga1ea64283508718d9d645c38efc2f4305":[5,1,0],
-"group__extended.html#ga220f29f40a44404b0061c15bc1c31152":[5,1,23],
+"group__extended.html#ga220f29f40a44404b0061c15bc1c31152":[5,1,25],
"group__extended.html#ga251d369cda3f1c2a955c555486ed90e5":[5,1,2],
"group__extended.html#ga299dae78d25ce112e384a98b7309c5be":[5,1,1],
-"group__extended.html#ga2d126e5c62d3badc35445e5d84166df2":[5,1,16],
-"group__extended.html#ga3132f521fb756fc0e8ec0b74fb58df50":[5,1,14],
-"group__extended.html#ga3460a6ca91af97be4058f523d3cb8ece":[5,1,10],
-"group__extended.html#ga3bb8468b8cfcc6e2a61d98aee85c5f99":[5,1,18],
+"group__extended.html#ga2d126e5c62d3badc35445e5d84166df2":[5,1,18],
+"group__extended.html#ga3132f521fb756fc0e8ec0b74fb58df50":[5,1,15],
+"group__extended.html#ga3460a6ca91af97be4058f523d3cb8ece":[5,1,11],
+"group__extended.html#ga3bb8468b8cfcc6e2a61d98aee85c5f99":[5,1,20],
"group__extended.html#ga421430e2226d7d468529cec457396756":[5,1,4],
-"group__extended.html#ga537f13b299ddf801e49a5a94fde02c79":[5,1,17],
+"group__extended.html#ga4c6486a1fdcd7a423b5f25fe4be8e0cf":[5,1,9],
+"group__extended.html#ga537f13b299ddf801e49a5a94fde02c79":[5,1,19],
"group__extended.html#ga5f071b10d4df1c3658e04e7fd67a94e6":[5,1,6],
"group__extended.html#ga7136c2e55cb22c98ecf95d08d6debb99":[5,1,8],
-"group__extended.html#ga7795a13d20087447281858d2c771cca1":[5,1,13],
-"group__extended.html#ga7d862c2affd5790381da14eb102a364d":[5,1,9],
-"group__extended.html#ga854b1de8cb067c7316286c28b2fcd3d1":[5,1,15],
-"group__extended.html#gaa1d55e0e894be240827e5d87ec3a1f45":[5,1,11],
+"group__extended.html#ga7795a13d20087447281858d2c771cca1":[5,1,14],
+"group__extended.html#ga7d862c2affd5790381da14eb102a364d":[5,1,10],
+"group__extended.html#ga854b1de8cb067c7316286c28b2fcd3d1":[5,1,17],
+"group__extended.html#gaa1d55e0e894be240827e5d87ec3a1f45":[5,1,12],
"group__extended.html#gaad25050b19f30cd79397b227e0157a3f":[5,1,7],
-"group__extended.html#gab1dac8476c46cb9eecab767eb40c1525":[5,1,21],
+"group__extended.html#gab1dac8476c46cb9eecab767eb40c1525":[5,1,23],
"group__extended.html#gac057927cd06c854b45fe7847e921bd47":[5,1,5],
"group__extended.html#gad823d23444a4b77a40f66bf075a98a0c":[5,1,3],
-"group__extended.html#gae5b17ff027cd2150b43a33040250cf3f":[5,1,12],
-"group__extended.html#gaf8e73efc2cbca9ebfdfb166983a04c17":[5,1,20],
+"group__extended.html#gae5b17ff027cd2150b43a33040250cf3f":[5,1,13],
+"group__extended.html#gaf8e73efc2cbca9ebfdfb166983a04c17":[5,1,22],
"group__heap.html":[5,3],
"group__heap.html#ga00e95ba1e01acac3cfd95bb7a357a6f0":[5,3,20],
"group__heap.html#ga08ca6419a5c057a4d965868998eef487":[5,3,3],
@@ -115,30 +118,32 @@ var NAVTREEINDEX0 =
"group__options.html#gaf84921c32375e25754dc2ee6a911fa60":[5,7,5],
"group__options.html#gafebf7ed116adb38ae5218bc3ce06884c":[5,7,0],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca0957ef73b2550764b4840edf48422fda":[5,7,0,1],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca0ac33a18f6b659fcfaf44efb0bab1b74":[5,7,0,11],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca154fe170131d5212cff57e22b99523c5":[5,7,0,10],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca17a190c25be381142d87e0468c4c068c":[5,7,0,13],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca0ac33a18f6b659fcfaf44efb0bab1b74":[5,7,0,12],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca154fe170131d5212cff57e22b99523c5":[5,7,0,11],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca17a190c25be381142d87e0468c4c068c":[5,7,0,14],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca1e8de72c93da7ff22d91e1e27b52ac2b":[5,7,0,3],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca2ecbe7ef32f5c84de3739aa4f0b805a1":[5,7,0,7],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca2ecbe7ef32f5c84de3739aa4f0b805a1":[5,7,0,8],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca32ce97ece29f69e82579679cf8a307ad":[5,7,0,4],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca4192d491200d0055df0554d4cf65054e":[5,7,0,5],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca4b74ae2a69e445de6c2361b73c1d14bf":[5,7,0,14],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca5b4357b74be0d87568036c32eb1a2e4a":[5,7,0,15],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca4b74ae2a69e445de6c2361b73c1d14bf":[5,7,0,15],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca5b4357b74be0d87568036c32eb1a2e4a":[5,7,0,16],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca7c8b7bf5281c581bad64f5daa6442777":[5,7,0,2],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cac81ee965b130fa81238913a3c239d536":[5,7,0,12],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884caa13e7926d4339d2aa6fbf61d4473fd5c":[5,7,0,7],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cac81ee965b130fa81238913a3c239d536":[5,7,0,13],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884caca7ed041be3b0b9d0b82432c7bf41af2":[5,7,0,6],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cada854dd272c66342f18a93ee254a2968":[5,7,0,8],
-"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cafb121d30d87591850d5410ccc3a95c6d":[5,7,0,9],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cada854dd272c66342f18a93ee254a2968":[5,7,0,9],
+"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cafb121d30d87591850d5410ccc3a95c6d":[5,7,0,10],
"group__options.html#ggafebf7ed116adb38ae5218bc3ce06884cafbf4822e5c00732c5984b32a032837f0":[5,7,0,0],
"group__posix.html":[5,8],
"group__posix.html#ga06d07cf357bbac5c73ba5d0c0c421e17":[5,8,7],
"group__posix.html#ga0d28d5cf61e6bfbb18c63092939fe5c9":[5,8,3],
"group__posix.html#ga1326d2e4388630b5f81ca7206318b8e5":[5,8,1],
"group__posix.html#ga4531c9e775bb3ae12db57c1ba8a5d7de":[5,8,6],
-"group__posix.html#ga48fad8648a2f1dab9c87ea9448a52088":[5,8,11],
+"group__posix.html#ga48fad8648a2f1dab9c87ea9448a52088":[5,8,12],
"group__posix.html#ga705dc7a64bffacfeeb0141501a5c35d7":[5,8,2],
"group__posix.html#ga72e9d7ffb5fe94d69bc722c8506e27bc":[5,8,5],
-"group__posix.html#ga73baaf5951f5165ba0763d0c06b6a93b":[5,8,12],
+"group__posix.html#ga73baaf5951f5165ba0763d0c06b6a93b":[5,8,13],
+"group__posix.html#ga7e1934d60a3e697950eeb48e042bfad5":[5,8,11],
"group__posix.html#gaab7fa71ea93b96873f5d9883db57d40e":[5,8,8],
"group__posix.html#gacff84f226ba9feb2031b8992e5579447":[5,8,9],
"group__posix.html#gad5a69c8fea96aa2b7a7c818c2130090a":[5,8,0],
diff --git a/docs/overrides.html b/docs/overrides.html
index 2a6c51e9a..0e7fd0ec8 100644
--- a/docs/overrides.html
+++ b/docs/overrides.html
@@ -3,7 +3,7 @@
-
+
mi-malloc: Overriding Malloc
@@ -13,10 +13,6 @@
-
@@ -37,12 +33,12 @@
(Note: in principle, it is possible to even patch existing executables without any recompilation if they are linked with the dynamic C runtime (ucrtbase.dll) – just put the mimalloc-override.dll into the import table (and put mimalloc-redirect.dll in the same folder) Such patching can be done for example with CFF Explorer).
Static override
On Unix systems, you can also statically link with mimalloc to override the standard malloc interface. The recommended way is to link the final program with the mimalloc single object file (mimalloc-override.o). We use an object file instead of a library file as linkers give preference to that over archives to resolve symbols. To ensure that the standard malloc interface resolves to the mimalloc library, link it as the first object file. For example:
diff --git a/docs/resize.js b/docs/resize.js
index 6617aee8e..e1ad0fe3b 100644
--- a/docs/resize.js
+++ b/docs/resize.js
@@ -1,25 +1,26 @@
/*
- @licstart The following is the entire license notice for the
- JavaScript code in this file.
+ @licstart The following is the entire license notice for the JavaScript code in this file.
- Copyright (C) 1997-2017 by Dimitri van Heesch
+ The MIT License (MIT)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ Copyright (C) 1997-2020 by Dimitri van Heesch
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
- @licend The above is the entire license notice
- for the JavaScript code in this file
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ @licend The above is the entire license notice for the JavaScript code in this file
*/
function initResizable()
{
@@ -91,6 +92,9 @@ function initResizable()
}
collapsedWidth=width;
}
+ if (location.hash.slice(1)) {
+ (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView();
+ }
}
function collapseExpand()
@@ -131,6 +135,6 @@ function initResizable()
var _preventDefault = function(evt) { evt.preventDefault(); };
$("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
$(".ui-resizable-handle").dblclick(collapseExpand);
- $(window).load(resizeHeight);
+ $(window).on('load',resizeHeight);
}
/* @license-end */
diff --git a/docs/search/all_0.html b/docs/search/all_0.html
index 5330204c2..1ec5b2d59 100644
--- a/docs/search/all_0.html
+++ b/docs/search/all_0.html
@@ -1,7 +1,8 @@
-
+
+
-
+
@@ -10,21 +11,27 @@
diff --git a/docs/search/pages_4.js b/docs/search/pages_4.js
index b47682a40..4e4e64dc4 100644
--- a/docs/search/pages_4.js
+++ b/docs/search/pages_4.js
@@ -1,4 +1,4 @@
var searchData=
[
- ['using_20the_20library',['Using the library',['../using.html',1,'']]]
+ ['using_20the_20library_328',['Using the library',['../using.html',1,'']]]
];
diff --git a/docs/search/search.js b/docs/search/search.js
index a554ab9cb..fb226f734 100644
--- a/docs/search/search.js
+++ b/docs/search/search.js
@@ -1,25 +1,26 @@
/*
- @licstart The following is the entire license notice for the
- JavaScript code in this file.
+ @licstart The following is the entire license notice for the JavaScript code in this file.
- Copyright (C) 1997-2017 by Dimitri van Heesch
+ The MIT License (MIT)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ Copyright (C) 1997-2020 by Dimitri van Heesch
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
- @licend The above is the entire license notice
- for the JavaScript code in this file
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ @licend The above is the entire license notice for the JavaScript code in this file
*/
function convertToId(search)
{
@@ -79,9 +80,10 @@ function getYPos(item)
storing this instance. Is needed to be able to set timeouts.
resultPath - path to use for external files
*/
-function SearchBox(name, resultsPath, inFrame, label)
+function SearchBox(name, resultsPath, inFrame, label, extension)
{
if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); }
+ if (!extension || extension == "") { extension = ".html"; }
// ---------- Instance variables
this.name = name;
@@ -96,6 +98,7 @@ function SearchBox(name, resultsPath, inFrame, label)
this.searchActive = false;
this.insideFrame = inFrame;
this.searchLabel = label;
+ this.extension = extension;
// ----------- DOM Elements
@@ -200,10 +203,9 @@ function SearchBox(name, resultsPath, inFrame, label)
}
return;
}
- else if (window.frames.MSearchResults.searchResults)
+ else
{
- var elem = window.frames.MSearchResults.searchResults.NavNext(0);
- if (elem) elem.focus();
+ window.frames.MSearchResults.postMessage("take_focus", "*");
}
}
else if (e.keyCode==27) // Escape out of the search field
@@ -347,13 +349,13 @@ function SearchBox(name, resultsPath, inFrame, label)
if (idx!=-1)
{
var hexCode=idx.toString(16);
- resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
+ resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + this.extension;
resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
hasResultsPage = true;
}
else // nothing available for this search term
{
- resultsPage = this.resultsPath + '/nomatches.html';
+ resultsPage = this.resultsPath + '/nomatches' + this.extension;
resultsPageWithSearch = resultsPage;
hasResultsPage = false;
}
@@ -364,7 +366,7 @@ function SearchBox(name, resultsPath, inFrame, label)
if (domPopupSearchResultsWindow.style.display!='block')
{
var domSearchBox = this.DOMSearchBox();
- this.DOMSearchClose().style.display = 'inline';
+ this.DOMSearchClose().style.display = 'inline-block';
if (this.insideFrame)
{
var domPopupSearchResults = this.DOMPopupSearchResults();
@@ -439,12 +441,12 @@ function SearchResults(name)
while (element && element!=parentElement)
{
- if (element.nodeName == 'DIV' && element.className == 'SRChildren')
+ if (element.nodeName.toLowerCase() == 'div' && element.className == 'SRChildren')
{
return element;
}
- if (element.nodeName == 'DIV' && element.hasChildNodes())
+ if (element.nodeName.toLowerCase() == 'div' && element.hasChildNodes())
{
element = element.firstChild;
}
diff --git a/docs/search/typedefs_0.html b/docs/search/typedefs_0.html
index 3848b20e9..a4684c4ad 100644
--- a/docs/search/typedefs_0.html
+++ b/docs/search/typedefs_0.html
@@ -1,7 +1,8 @@
-
+
+
-
+
@@ -10,21 +11,27 @@
The preferred usage is including <mimalloc.h>, linking with the shared- or static library, and using the mi_malloc API exclusively for allocation. For example,
gcc -o myprogram -lmimalloc myfile.c
mimalloc uses only safe OS calls (mmap and VirtualAlloc) and can co-exist with other allocators linked to the same program. If you use cmake, you can simply use:
find_package(mimalloc 1.0 REQUIRED)
in your CMakeLists.txt to find a locally installed mimalloc. Then use either:
target_link_libraries(myapp PUBLIC mimalloc)
to link with the shared (dynamic) library, or:
target_link_libraries(myapp PUBLIC mimalloc-static)
to link with the static library. See test\CMakeLists.txt for an example.
+
The preferred usage is including <mimalloc.h>, linking with the shared- or static library, and using the mi_malloc API exclusively for allocation. For example,
gcc -o myprogram -lmimalloc myfile.c
+
mimalloc uses only safe OS calls (mmap and VirtualAlloc) and can co-exist with other allocators linked to the same program. If you use cmake, you can simply use:
find_package(mimalloc 1.0 REQUIRED)
+
in your CMakeLists.txt to find a locally installed mimalloc. Then use either:
target_link_libraries(myapp PUBLIC mimalloc)
+
to link with the shared (dynamic) library, or:
target_link_libraries(myapp PUBLIC mimalloc-static)
+
to link with the static library. See test\CMakeLists.txt for an example.
C++
For best performance in C++ programs, it is also recommended to override the global new and delete operators. For convience, mimalloc provides mimalloc-new-delete.h which does this for you – just include it in a single(!) source file in your project.
-
In C++, mimalloc also provides the mi_stl_allocator struct which implements the std::allocator interface. For example:
The above model of using the mi_ prefixed API is not always possible though in existing programs that already use the standard malloc interface, and another option is to override the standard malloc interface completely and redirect all calls to the mimalloc library instead.
+
In C++, mimalloc also provides the mi_stl_allocator struct which implements the std::allocator interface. For example:
The above model of using the mi_ prefixed API is not always possible though in existing programs that already use the standard malloc interface, and another option is to override the standard malloc interface completely and redirect all calls to the mimalloc library instead.
From 424c8f84489108129bf741728663926cfd119960 Mon Sep 17 00:00:00 2001
From: daan
Date: Sat, 18 Dec 2021 16:38:03 -0800
Subject: [PATCH 045/131] update docs
---
doc/doxyfile | 281 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 188 insertions(+), 93 deletions(-)
diff --git a/doc/doxyfile b/doc/doxyfile
index 6c1e30a0d..73266f4e9 100644
--- a/doc/doxyfile
+++ b/doc/doxyfile
@@ -1,4 +1,4 @@
-# Doxyfile 1.8.15
+# Doxyfile 1.9.1
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -38,7 +38,7 @@ PROJECT_NAME = mi-malloc
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.6
+PROJECT_NUMBER = 1.7/2.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -197,6 +197,16 @@ SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
+# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
+# such as
+# /***************
+# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
+# Javadoc-style will behave just like regular comments and it will not be
+# interpreted by doxygen.
+# The default value is: NO.
+
+JAVADOC_BANNER = NO
+
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
@@ -217,6 +227,14 @@ QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
+# By default Python docstrings are displayed as preformatted text and doxygen's
+# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the
+# doxygen's special commands can be used and the contents of the docstring
+# documentation blocks is shown as doxygen documentation.
+# The default value is: YES.
+
+PYTHON_DOCSTRING = YES
+
# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
# documentation from any documented member that it re-implements.
# The default value is: YES.
@@ -253,12 +271,6 @@ TAB_SIZE = 2
ALIASES =
-# This tag can be used to specify a number of word-keyword mappings (TCL only).
-# A mapping has the form "name=value". For example adding "class=itcl::class"
-# will allow you to use the command class in the itcl::class meaning.
-
-TCL_SUBST =
-
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all
@@ -299,19 +311,22 @@ OPTIMIZE_OUTPUT_SLICE = NO
# parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and
-# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
-# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice,
+# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
+# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL,
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
# tries to guess whether the code is fixed or free formatted code, this is the
-# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat
-# .inc files as Fortran files (default is PHP), and .f files as C (default is
-# Fortran), use: inc=Fortran f=C.
+# default for Fortran type files). For instance to make doxygen treat .inc files
+# as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C.
#
# Note: For files without extension you can use no_extension as a placeholder.
#
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
-# the files are not read by doxygen.
+# the files are not read by doxygen. When specifying no_extension you should add
+# * to the FILE_PATTERNS.
+#
+# Note see also the list of default file extension mappings.
EXTENSION_MAPPING =
@@ -329,7 +344,7 @@ MARKDOWN_SUPPORT = YES
# to that level are automatically included in the table of contents, even if
# they do not have an id attribute.
# Note: This feature currently applies only to Markdown headings.
-# Minimum value: 0, maximum value: 99, default value: 0.
+# Minimum value: 0, maximum value: 99, default value: 5.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 0
@@ -445,6 +460,19 @@ TYPEDEF_HIDES_STRUCT = YES
LOOKUP_CACHE_SIZE = 0
+# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use
+# during processing. When set to 0 doxygen will based this on the number of
+# cores available in the system. You can set it explicitly to a value larger
+# than 0 to get more control over the balance between CPU load and processing
+# speed. At this moment only the input processing can be done using multiple
+# threads. Since this is still an experimental feature the default is set to 1,
+# which efficively disables parallel processing. Please report any issues you
+# encounter. Generating dot graphs in parallel is controlled by the
+# DOT_NUM_THREADS setting.
+# Minimum value: 0, maximum value: 32, default value: 1.
+
+NUM_PROC_THREADS = 1
+
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
@@ -465,6 +493,12 @@ EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
+# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
+# methods of a class will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIV_VIRTUAL = NO
+
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
# The default value is: NO.
@@ -502,6 +536,13 @@ EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
+# If this flag is set to YES, the name of an unnamed parameter in a declaration
+# will be determined by the corresponding definition. By default unnamed
+# parameters remain unnamed in the output.
+# The default value is: YES.
+
+RESOLVE_UNNAMED_PARAMS = YES
+
# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
# undocumented members inside documented classes or files. If set to NO these
# members will be included in the various overviews, but no documentation
@@ -519,8 +560,8 @@ HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
-# (class|struct|union) declarations. If set to NO, these declarations will be
-# included in the documentation.
+# declarations. If set to NO, these declarations will be included in the
+# documentation.
# The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO
@@ -539,11 +580,18 @@ HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
-# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
-# names in lower-case letters. If set to YES, upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
+# With the correct setting of option CASE_SENSE_NAMES doxygen will better be
+# able to match the capabilities of the underlying filesystem. In case the
+# filesystem is case sensitive (i.e. it supports files in the same directory
+# whose names only differ in casing), the option must be set to YES to properly
+# deal with such files in case they appear in the input. For filesystems that
+# are not case sensitive the option should be be set to NO to properly deal with
+# output files written for symbols that only differ in casing, such as for two
+# classes, one named CLASS and the other named Class, and to also support
+# references to files without having to specify the exact matching casing. On
+# Windows (including Cygwin) and MacOS, users should typically set this option
+# to NO, whereas on Linux or other Unix flavors it should typically be set to
+# YES.
# The default value is: system dependent.
CASE_SENSE_NAMES = NO
@@ -782,7 +830,10 @@ WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
-# a warning is encountered.
+# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS
+# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but
+# at the end of the doxygen process doxygen will return with a non-zero status.
+# Possible values are: NO, YES and FAIL_ON_WARNINGS.
# The default value is: NO.
WARN_AS_ERROR = NO
@@ -818,8 +869,8 @@ INPUT = mimalloc-doc.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
-# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
-# possible encodings.
+# documentation (see:
+# https://www.gnu.org/software/libiconv/) for the list of possible encodings.
# The default value is: UTF-8.
INPUT_ENCODING = UTF-8
@@ -832,11 +883,15 @@ INPUT_ENCODING = UTF-8
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# read by doxygen.
#
+# Note the list of default checked file patterns might differ from the list of
+# default file extension mappings.
+#
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
-# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
-# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
+# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
+# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl,
+# *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.c \
*.cc \
@@ -1094,16 +1149,22 @@ USE_HTAGS = NO
VERBATIM_HEADERS = YES
# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
-# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
-# cost of reduced performance. This can be particularly helpful with template
-# rich C++ code for which doxygen's built-in parser lacks the necessary type
-# information.
+# clang parser (see:
+# http://clang.llvm.org/) for more accurate parsing at the cost of reduced
+# performance. This can be particularly helpful with template rich C++ code for
+# which doxygen's built-in parser lacks the necessary type information.
# Note: The availability of this option depends on whether or not doxygen was
# generated with the -Duse_libclang=ON option for CMake.
# The default value is: NO.
CLANG_ASSISTED_PARSING = NO
+# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to
+# YES then doxygen will add the directory of each input to the include path.
+# The default value is: YES.
+
+CLANG_ADD_INC_PATHS = YES
+
# If clang assisted parsing is enabled you can provide the compiler with command
# line options that you would normally use when invoking the compiler. Note that
# the include paths will already be set by doxygen for the files and directories
@@ -1113,10 +1174,13 @@ CLANG_ASSISTED_PARSING = NO
CLANG_OPTIONS =
# If clang assisted parsing is enabled you can provide the clang parser with the
-# path to the compilation database (see:
-# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files
-# were built. This is equivalent to specifying the "-p" option to a clang tool,
-# such as clang-check. These options will then be passed to the parser.
+# path to the directory containing a file called compile_commands.json. This
+# file is the compilation database (see:
+# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the
+# options used when the source files were built. This is equivalent to
+# specifying the -p option to a clang tool, such as clang-check. These options
+# will then be passed to the parser. Any options specified with CLANG_OPTIONS
+# will be added as well.
# Note: The availability of this option depends on whether or not doxygen was
# generated with the -Duse_libclang=ON option for CMake.
@@ -1133,13 +1197,6 @@ CLANG_DATABASE_PATH =
ALPHABETICAL_INDEX = YES
-# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
-# which the alphabetical index list will be split.
-# Minimum value: 1, maximum value: 20, default value: 5.
-# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
-
-COLS_IN_ALPHA_INDEX = 5
-
# In case all classes in a project start with a common prefix, all classes will
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
# can be used to specify a prefix (or a list of prefixes) that should be ignored
@@ -1278,9 +1335,9 @@ HTML_TIMESTAMP = NO
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that
-# are dynamically created via Javascript. If disabled, the navigation index will
+# are dynamically created via JavaScript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML
-# page. Disable this option to support browsers that do not have Javascript,
+# page. Disable this option to support browsers that do not have JavaScript,
# like the Qt help browser.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1310,10 +1367,11 @@ HTML_INDEX_NUM_ENTRIES = 100
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
# generated that can be used as input for Apple's Xcode 3 integrated development
-# environment (see: https://developer.apple.com/xcode/), introduced with OSX
-# 10.5 (Leopard). To create a documentation set, doxygen will generate a
-# Makefile in the HTML output directory. Running make will produce the docset in
-# that directory and running make install will install the docset in
+# environment (see:
+# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To
+# create a documentation set, doxygen will generate a Makefile in the HTML
+# output directory. Running make will produce the docset in that directory and
+# running make install will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy
# genXcode/_index.html for more information.
@@ -1355,8 +1413,8 @@ DOCSET_PUBLISHER_NAME = Publisher
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
-# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on
-# Windows.
+# (see:
+# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows.
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
@@ -1386,7 +1444,7 @@ CHM_FILE =
HHC_LOCATION =
# The GENERATE_CHI flag controls if a separate .chi index file is generated
-# (YES) or that it should be included in the master .chm file (NO).
+# (YES) or that it should be included in the main .chm file (NO).
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
@@ -1431,7 +1489,8 @@ QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
-# (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
+# (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1439,8 +1498,8 @@ QHP_NAMESPACE = org.doxygen.Project
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
-# Folders (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-
-# folders).
+# Folders (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1448,30 +1507,30 @@ QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
-# filters).
+# Filters (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
-# filters).
+# Filters (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
-# http://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS =
-# The QHG_LOCATION tag can be used to specify the location of Qt's
-# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
-# generated .qhp file.
+# The QHG_LOCATION tag can be used to specify the location (absolute path
+# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to
+# run qhelpgenerator on the generated .qhp file.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHG_LOCATION =
@@ -1548,6 +1607,17 @@ TREEVIEW_WIDTH = 180
EXT_LINKS_IN_WINDOW = NO
+# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg
+# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
+# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
+# the HTML output. These images will generally look nicer at scaled resolutions.
+# Possible values are: png (the default) and svg (looks nicer but requires the
+# pdf2svg or inkscape tool).
+# The default value is: png.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FORMULA_FORMAT = png
+
# Use this tag to change the font size of LaTeX formulas included as images in
# the HTML documentation. When you change the font size after a successful
# doxygen run you need to manually remove any form_*.png images from the HTML
@@ -1568,8 +1638,14 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
+# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
+# to create new LaTeX commands to be used in formulas as building blocks. See
+# the section "Including formulas" for details.
+
+FORMULA_MACROFILE =
+
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
-# https://www.mathjax.org) which uses client side Javascript for the rendering
+# https://www.mathjax.org) which uses client side JavaScript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
@@ -1581,7 +1657,7 @@ USE_MATHJAX = NO
# When MathJax is enabled you can set the default output format to be used for
# the MathJax output. See the MathJax site (see:
-# http://docs.mathjax.org/en/latest/output.html) for more details.
+# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details.
# Possible values are: HTML-CSS (which is slower, but has the best
# compatibility), NativeMML (i.e. MathML) and SVG.
# The default value is: HTML-CSS.
@@ -1597,7 +1673,7 @@ MATHJAX_FORMAT = HTML-CSS
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from https://www.mathjax.org before deployment.
-# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/.
+# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
@@ -1611,7 +1687,8 @@ MATHJAX_EXTENSIONS =
# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
# of code that will be used on startup of the MathJax code. See the MathJax site
-# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# (see:
+# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an
# example see the documentation.
# This tag requires that the tag USE_MATHJAX is set to YES.
@@ -1639,7 +1716,7 @@ MATHJAX_CODEFILE =
SEARCHENGINE = YES
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
-# implemented using a web server instead of a web client using Javascript. There
+# implemented using a web server instead of a web client using JavaScript. There
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
# setting. When disabled, doxygen will generate a PHP script for searching and
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
@@ -1658,7 +1735,8 @@ SERVER_BASED_SEARCH = NO
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: https://xapian.org/).
+# Xapian (see:
+# https://xapian.org/).
#
# See the section "External Indexing and Searching" for details.
# The default value is: NO.
@@ -1671,8 +1749,9 @@ EXTERNAL_SEARCH = NO
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: https://xapian.org/). See the section "External Indexing and
-# Searching" for details.
+# Xapian (see:
+# https://xapian.org/). See the section "External Indexing and Searching" for
+# details.
# This tag requires that the tag SEARCHENGINE is set to YES.
SEARCHENGINE_URL =
@@ -1743,10 +1822,11 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
-# generate index for LaTeX.
+# generate index for LaTeX. In case there is no backslash (\) as first character
+# it will be automatically added in the LaTeX code.
# Note: This tag is used in the generated output file (.tex).
# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
-# The default value is: \makeindex.
+# The default value is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_MAKEINDEX_CMD = \makeindex
@@ -1835,9 +1915,11 @@ LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
-# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
-# the PDF file directly from the LaTeX files. Set this option to YES, to get a
-# higher quality PDF documentation.
+# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as
+# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX
+# files. Set this option to YES, to get a higher quality PDF documentation.
+#
+# See also section LATEX_CMD_NAME for selecting the engine.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -2076,6 +2158,10 @@ DOCBOOK_PROGRAMLISTING = NO
GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# Configuration options related to Sqlite3 output
+#---------------------------------------------------------------------------
+
#---------------------------------------------------------------------------
# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
@@ -2238,12 +2324,6 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of 'which perl').
-# The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH = /usr/bin/perl
-
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
@@ -2257,15 +2337,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = YES
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see:
-# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
@@ -2363,10 +2434,32 @@ UML_LOOK = NO
# but if the number exceeds 15, the total amount of fields shown is limited to
# 10.
# Minimum value: 0, maximum value: 100, default value: 10.
-# This tag requires that the tag HAVE_DOT is set to YES.
+# This tag requires that the tag UML_LOOK is set to YES.
UML_LIMIT_NUM_FIELDS = 10
+# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and
+# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS
+# tag is set to YES, doxygen will add type and arguments for attributes and
+# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen
+# will not generate fields with class member information in the UML graphs. The
+# class diagrams will look similar to the default class diagrams but using UML
+# notation for the relationships.
+# Possible values are: NO, YES and NONE.
+# The default value is: NO.
+# This tag requires that the tag UML_LOOK is set to YES.
+
+DOT_UML_DETAILS = NO
+
+# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters
+# to display on a single line. If the actual line length exceeds this threshold
+# significantly it will wrapped across multiple lines. Some heuristics are apply
+# to avoid ugly line breaks.
+# Minimum value: 0, maximum value: 1000, default value: 17.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_WRAP_THRESHOLD = 17
+
# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
# collaboration graphs will show the relations between templates and their
# instances.
@@ -2556,9 +2649,11 @@ DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
-# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate
# files that are used to generate the various graphs.
+#
+# Note: This setting is not only used for dot files but also for msc and
+# plantuml temporary files.
# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
DOT_CLEANUP = YES
From ff3bb5ce7b45272b6a97b042bbcddcd7bbc50346 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 14:51:15 +0100
Subject: [PATCH 046/131] Tweak documentation for mi_heap_area_t::used.
For microsoft/mimalloc#503.
---
include/mimalloc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/mimalloc.h b/include/mimalloc.h
index 756e516cb..420e0eab2 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -253,7 +253,7 @@ typedef struct mi_heap_area_s {
void* blocks; // start of the area containing heap blocks
size_t reserved; // bytes reserved for this area (virtual)
size_t committed; // current available bytes for this area
- size_t used; // bytes in use by allocated blocks
+ size_t used; // number of allocated blocks
size_t block_size; // size in bytes of each block
} mi_heap_area_t;
From dd642ea2a8f5113023a0d686644383c819add5d2 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 15:10:36 +0100
Subject: [PATCH 047/131] Replace mi_strlcpy() and mi_strlcat() with versions
written from scratch
They used strncpy() and strncat(), which behave almost, but not
quite like the ...l... functions.
Since these functions are not standard, and not all OSes have
comparable functions available, just add a implementations.
Addresses first issue raised in microsoft/mimalloc#502.
---
src/options.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/options.c b/src/options.c
index 43f8fb4b1..259ba7f92 100644
--- a/src/options.c
+++ b/src/options.c
@@ -400,14 +400,27 @@ void _mi_error_message(int err, const char* fmt, ...) {
// --------------------------------------------------------
static void mi_strlcpy(char* dest, const char* src, size_t dest_size) {
- dest[0] = 0;
- strncpy(dest, src, dest_size - 1);
- dest[dest_size - 1] = 0;
+ if (dest_size == 0)
+ return;
+
+ // Copy until end of 'src' or dest is (almost) full
+ while (*src && (dest_size > 1)) {
+ *dest++ = *src++;
+ --dest_size;
+ }
+ // Null-terminate dest
+ *dest = 0;
}
static void mi_strlcat(char* dest, const char* src, size_t dest_size) {
- strncat(dest, src, dest_size - 1);
- dest[dest_size - 1] = 0;
+ // Skip existing data in 'dest'
+ while (*dest && (dest_size > 1)) {
+ ++dest;
+ --dest_size;
+ }
+
+ // Concatenate src
+ mi_strlcpy(dest, src, dest_size);
}
#ifdef MI_NO_GETENV
From 5d92b5f6d3ecc34fcf4810d75837e0c0e1c6f64d Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 15:46:46 +0100
Subject: [PATCH 048/131] Avoid a possible infinite recursion in options
parsing.
See microsoft/mimalloc#502, second issue, for a scenario where this occurs.
---
src/options.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/options.c b/src/options.c
index 43f8fb4b1..df9f3b3cd 100644
--- a/src/options.c
+++ b/src/options.c
@@ -532,8 +532,11 @@ static void mi_option_init(mi_option_desc_t* desc) {
desc->init = INITIALIZED;
}
else {
- _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
+ /* _mi_warning_message() will itself call mi_option_get() for some options,
+ * so to avoid a possible infinite recursion it's important to mark the option as
+ * "initialized" first */
desc->init = DEFAULTED;
+ _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
}
}
mi_assert_internal(desc->init != UNINIT);
From f7c821fe7927b92212ae3d2c149c0a8b77d3845d Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 15:56:26 +0100
Subject: [PATCH 049/131] options: Always print a warning if the 'verbose'
option value is bogus
---
src/options.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/options.c b/src/options.c
index df9f3b3cd..f9e3984a5 100644
--- a/src/options.c
+++ b/src/options.c
@@ -536,7 +536,15 @@ static void mi_option_init(mi_option_desc_t* desc) {
* so to avoid a possible infinite recursion it's important to mark the option as
* "initialized" first */
desc->init = DEFAULTED;
+ if (desc->option == mi_option_verbose) {
+ /* Special case: if the 'mimalloc_verbose' env var has a bogus value we'd never know
+ * (since the value default to 'off') - so in that one case briefly set the option to 'on' */
+ desc->value = 1;
+ }
_mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
+ if (desc->option == mi_option_verbose) {
+ desc->value = 0;
+ }
}
}
mi_assert_internal(desc->init != UNINIT);
From 1ca48210fb7bae627799c3a894ed9e029cf95fb3 Mon Sep 17 00:00:00 2001
From: Daan
Date: Sun, 19 Dec 2021 10:01:53 -0800
Subject: [PATCH 050/131] small rewrite of pr #506
---
src/options.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/options.c b/src/options.c
index a2ffcbf1d..8b4d07e88 100644
--- a/src/options.c
+++ b/src/options.c
@@ -545,19 +545,18 @@ static void mi_option_init(mi_option_desc_t* desc) {
desc->init = INITIALIZED;
}
else {
- /* _mi_warning_message() will itself call mi_option_get() for some options,
- * so to avoid a possible infinite recursion it's important to mark the option as
- * "initialized" first */
+ // set `init` first to avoid recursion through _mi_warning_message on mimalloc_verbose.
desc->init = DEFAULTED;
- if (desc->option == mi_option_verbose) {
- /* Special case: if the 'mimalloc_verbose' env var has a bogus value we'd never know
- * (since the value default to 'off') - so in that one case briefly set the option to 'on' */
+ if (desc->option == mi_option_verbose && desc->value == 0) {
+ // if the 'mimalloc_verbose' env var has a bogus value we'd never know
+ // (since the value defaults to 'off') so in that case briefly enable verbose
desc->value = 1;
- }
- _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
- if (desc->option == mi_option_verbose) {
+ _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
desc->value = 0;
}
+ else {
+ _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
+ }
}
}
mi_assert_internal(desc->init != UNINIT);
From babe57aa9972f0dfcad6727ee08677af048b0828 Mon Sep 17 00:00:00 2001
From: Daan
Date: Sun, 19 Dec 2021 10:22:48 -0800
Subject: [PATCH 051/131] fix too early tlv access on macOS in the recursion
check
---
src/options.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/options.c b/src/options.c
index 8b4d07e88..b90e6619d 100644
--- a/src/options.c
+++ b/src/options.c
@@ -257,22 +257,37 @@ static _Atomic(size_t) warning_count; // = 0; // when >= max_warning_count stop
// When overriding malloc, we may recurse into mi_vfprintf if an allocation
// inside the C runtime causes another message.
+// In some cases (like on macOS) the loader already allocates which
+// calls into mimalloc; if we then access thread locals (like `recurse`)
+// this may crash as the access may call _tlv_bootstrap that tries to
+// (recursively) invoke malloc again to allocate space for the thread local
+// variables on demand. This is why we use a _mi_preloading test on such
+// platforms. However, code gen may move the initial thread local address
+// load before the `if` and we therefore split it out in a separate funcion.
static mi_decl_thread bool recurse = false;
+static mi_decl_noinline bool mi_recurse_enter_prim(void) {
+ if (recurse) return false;
+ recurse = true;
+ return true;
+}
+
+static mi_decl_noinline void mi_recurse_exit_prim(void) {
+ recurse = false;
+}
+
static bool mi_recurse_enter(void) {
#if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD)
if (_mi_preloading()) return true;
#endif
- if (recurse) return false;
- recurse = true;
- return true;
+ return mi_recurse_enter_prim();
}
static void mi_recurse_exit(void) {
#if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD)
if (_mi_preloading()) return;
#endif
- recurse = false;
+ mi_recurse_exit_prim();
}
void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* message) {
From 4808ef762b72365cc0e9d504c22421e383829744 Mon Sep 17 00:00:00 2001
From: Daan
Date: Sun, 19 Dec 2021 10:35:12 -0800
Subject: [PATCH 052/131] small rewrite of PR #505
---
src/options.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/options.c b/src/options.c
index b90e6619d..00d93369d 100644
--- a/src/options.c
+++ b/src/options.c
@@ -415,26 +415,24 @@ void _mi_error_message(int err, const char* fmt, ...) {
// --------------------------------------------------------
static void mi_strlcpy(char* dest, const char* src, size_t dest_size) {
- if (dest_size == 0)
- return;
-
- // Copy until end of 'src' or dest is (almost) full
- while (*src && (dest_size > 1)) {
+ if (dest==NULL || src==NULL || dest_size == 0) return;
+ // copy until end of src, or when dest is (almost) full
+ while (*src != 0 && dest_size > 1) {
*dest++ = *src++;
- --dest_size;
+ dest_size--;
}
- // Null-terminate dest
+ // always zero terminate
*dest = 0;
}
static void mi_strlcat(char* dest, const char* src, size_t dest_size) {
- // Skip existing data in 'dest'
- while (*dest && (dest_size > 1)) {
- ++dest;
- --dest_size;
+ if (dest==NULL || src==NULL || dest_size == 0) return;
+ // find end of string in the dest buffer
+ while (*dest != 0 && dest_size > 1) {
+ dest++;
+ dest_size--;
}
-
- // Concatenate src
+ // and catenate
mi_strlcpy(dest, src, dest_size);
}
From 5a7685de0e3dd900feb7f08eee8df67813021647 Mon Sep 17 00:00:00 2001
From: Daan
Date: Sun, 19 Dec 2021 10:37:10 -0800
Subject: [PATCH 053/131] for safety do not print illegal environment values
---
src/options.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/options.c b/src/options.c
index 00d93369d..24668c5ce 100644
--- a/src/options.c
+++ b/src/options.c
@@ -564,11 +564,11 @@ static void mi_option_init(mi_option_desc_t* desc) {
// if the 'mimalloc_verbose' env var has a bogus value we'd never know
// (since the value defaults to 'off') so in that case briefly enable verbose
desc->value = 1;
- _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
+ _mi_warning_message("environment option mimalloc_%s has an invalid value.\n", desc->name );
desc->value = 0;
}
else {
- _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
+ _mi_warning_message("environment option mimalloc_%s has an invalid value.\n", desc->name );
}
}
}
From 7d0623472410e1f8aa2b38719c7bc858d9b4cc35 Mon Sep 17 00:00:00 2001
From: Daan
Date: Sun, 19 Dec 2021 15:29:58 -0800
Subject: [PATCH 054/131] comments
---
src/options.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/options.c b/src/options.c
index 24668c5ce..c4ed91cba 100644
--- a/src/options.c
+++ b/src/options.c
@@ -262,7 +262,7 @@ static _Atomic(size_t) warning_count; // = 0; // when >= max_warning_count stop
// this may crash as the access may call _tlv_bootstrap that tries to
// (recursively) invoke malloc again to allocate space for the thread local
// variables on demand. This is why we use a _mi_preloading test on such
-// platforms. However, code gen may move the initial thread local address
+// platforms. However, C code generator may move the initial thread local address
// load before the `if` and we therefore split it out in a separate funcion.
static mi_decl_thread bool recurse = false;
@@ -551,7 +551,8 @@ static void mi_option_init(mi_option_desc_t* desc) {
else if (*end == 'M') { value *= MI_KiB; end++; }
else if (*end == 'G') { value *= MI_MiB; end++; }
else { value = (value + MI_KiB - 1) / MI_KiB; }
- if (*end == 'B') { end++; }
+ if (end[0] == 'I' && end[1] == 'B') { end += 2; }
+ else if (*end == 'B') { end++; }
}
if (*end == 0) {
desc->value = value;
From d508c3d61837f4f37100895b02d38d0df8de6a14 Mon Sep 17 00:00:00 2001
From: Daan Leijen
Date: Mon, 20 Dec 2021 12:33:54 -0800
Subject: [PATCH 055/131] ensure in debug mode that all allocated block are
initialized with MI_DEBUG_UNINIT (issue #501)
---
src/page.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/page.c b/src/page.c
index c0659395d..3368bad17 100644
--- a/src/page.c
+++ b/src/page.c
@@ -621,7 +621,11 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi
page->keys[0] = _mi_heap_random_next(heap);
page->keys[1] = _mi_heap_random_next(heap);
#endif
+ #if MI_DEBUG > 0
+ page->is_zero = false; // ensure in debug mode we initialize with MI_DEBUG_UNINIT, see issue #501
+ #else
page->is_zero = page->is_zero_init;
+ #endif
mi_assert_internal(page->capacity == 0);
mi_assert_internal(page->free == NULL);
From d7105c20a9020116bd5bdbacaa61e9458f53ea52 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Tue, 21 Dec 2021 12:39:17 +0100
Subject: [PATCH 056/131] Move test macros/helpers to a separate header
---
test/test-api.c | 34 ++------------------------------
test/testhelper.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 32 deletions(-)
create mode 100644 test/testhelper.h
diff --git a/test/test-api.c b/test/test-api.c
index f057799a5..8ecd31a18 100644
--- a/test/test-api.c
+++ b/test/test-api.c
@@ -23,7 +23,6 @@ we therefore test the API over various inputs. Please add more tests :-)
[1] https://github.com/daanx/mimalloc-bench
*/
-#include
#include
#include
#include
@@ -36,33 +35,7 @@ we therefore test the API over various inputs. Please add more tests :-)
#include "mimalloc.h"
// #include "mimalloc-internal.h"
-// ---------------------------------------------------------------------------
-// Test macros: CHECK(name,predicate) and CHECK_BODY(name,body)
-// ---------------------------------------------------------------------------
-static int ok = 0;
-static int failed = 0;
-
-#define CHECK_BODY(name,body) \
- do { \
- fprintf(stderr,"test: %s... ", name ); \
- bool result = true; \
- do { body } while(false); \
- if (!(result)) { \
- failed++; \
- fprintf(stderr, \
- "\n FAILED: %s:%d:\n %s\n", \
- __FILE__, \
- __LINE__, \
- #body); \
- /* exit(1); */ \
- } \
- else { \
- ok++; \
- fprintf(stderr,"ok.\n"); \
- } \
- } while (false)
-
-#define CHECK(name,expr) CHECK_BODY(name,{ result = (expr); })
+#include "testhelper.h"
// ---------------------------------------------------------------------------
// Test functions
@@ -219,10 +192,7 @@ int main(void) {
// ---------------------------------------------------
// Done
// ---------------------------------------------------[]
- fprintf(stderr,"\n\n---------------------------------------------\n"
- "succeeded: %i\n"
- "failed : %i\n\n", ok, failed);
- return failed;
+ return print_test_summary();
}
// ---------------------------------------------------
diff --git a/test/testhelper.h b/test/testhelper.h
new file mode 100644
index 000000000..46d63a005
--- /dev/null
+++ b/test/testhelper.h
@@ -0,0 +1,49 @@
+/* ----------------------------------------------------------------------------
+Copyright (c) 2018-2020, Microsoft Research, Daan Leijen
+This is free software; you can redistribute it and/or modify it under the
+terms of the MIT license. A copy of the license can be found in the file
+"LICENSE" at the root of this distribution.
+-----------------------------------------------------------------------------*/
+#ifndef TESTHELPER_H_
+#define TESTHELPER_H_
+
+#include
+
+// ---------------------------------------------------------------------------
+// Test macros: CHECK(name,predicate) and CHECK_BODY(name,body)
+// ---------------------------------------------------------------------------
+static int ok = 0;
+static int failed = 0;
+
+#define CHECK_BODY(name,body) \
+ do { \
+ fprintf(stderr,"test: %s... ", name ); \
+ bool result = true; \
+ do { body } while(false); \
+ if (!(result)) { \
+ failed++; \
+ fprintf(stderr, \
+ "\n FAILED: %s:%d:\n %s\n", \
+ __FILE__, \
+ __LINE__, \
+ #body); \
+ /* exit(1); */ \
+ } \
+ else { \
+ ok++; \
+ fprintf(stderr,"ok.\n"); \
+ } \
+ } while (false)
+
+#define CHECK(name,expr) CHECK_BODY(name,{ result = (expr); })
+
+// Print summary of test. Return value can be directly use as a return value for main().
+static inline int print_test_summary(void)
+{
+ fprintf(stderr,"\n\n---------------------------------------------\n"
+ "succeeded: %i\n"
+ "failed : %i\n\n", ok, failed);
+ return failed;
+}
+
+#endif // TESTHELPER_H_
From 51271ba8ea47e250d22fe6b7a2f6813c07336cca Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Tue, 21 Dec 2021 12:54:15 +0100
Subject: [PATCH 057/131] Replace redundant CMake code for tests with a loop
---
CMakeLists.txt | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d52a72dd..5a682bf72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -373,21 +373,17 @@ endif()
# -----------------------------------------------------------------------------
if (MI_BUILD_TESTS)
- add_executable(mimalloc-test-api test/test-api.c)
- target_compile_definitions(mimalloc-test-api PRIVATE ${mi_defines})
- target_compile_options(mimalloc-test-api PRIVATE ${mi_cflags})
- target_include_directories(mimalloc-test-api PRIVATE include)
- target_link_libraries(mimalloc-test-api PRIVATE mimalloc ${mi_libraries})
-
- add_executable(mimalloc-test-stress test/test-stress.c)
- target_compile_definitions(mimalloc-test-stress PRIVATE ${mi_defines})
- target_compile_options(mimalloc-test-stress PRIVATE ${mi_cflags})
- target_include_directories(mimalloc-test-stress PRIVATE include)
- target_link_libraries(mimalloc-test-stress PRIVATE mimalloc ${mi_libraries})
-
enable_testing()
- add_test(test_api, mimalloc-test-api)
- add_test(test_stress, mimalloc-test-stress)
+
+ foreach(TEST_NAME api stress)
+ add_executable(mimalloc-test-${TEST_NAME} test/test-${TEST_NAME}.c)
+ target_compile_definitions(mimalloc-test-${TEST_NAME} PRIVATE ${mi_defines})
+ target_compile_options(mimalloc-test-${TEST_NAME} PRIVATE ${mi_cflags})
+ target_include_directories(mimalloc-test-${TEST_NAME} PRIVATE include)
+ target_link_libraries(mimalloc-test-${TEST_NAME} PRIVATE mimalloc ${mi_libraries})
+
+ add_test(NAME test-${TEST_NAME} COMMAND mimalloc-test-${TEST_NAME})
+ endforeach()
endif()
# -----------------------------------------------------------------------------
From 969f3a6998c194d3f359072e5e6067b1581965e7 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 19:45:39 +0100
Subject: [PATCH 058/131] Add tests for zero-initialization functions
---
CMakeLists.txt | 2 +-
test/test-api-fill.c | 180 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 181 insertions(+), 1 deletion(-)
create mode 100644 test/test-api-fill.c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a682bf72..47366c49b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -375,7 +375,7 @@ endif()
if (MI_BUILD_TESTS)
enable_testing()
- foreach(TEST_NAME api stress)
+ foreach(TEST_NAME api api-fill stress)
add_executable(mimalloc-test-${TEST_NAME} test/test-${TEST_NAME}.c)
target_compile_definitions(mimalloc-test-${TEST_NAME} PRIVATE ${mi_defines})
target_compile_options(mimalloc-test-${TEST_NAME} PRIVATE ${mi_cflags})
diff --git a/test/test-api-fill.c b/test/test-api-fill.c
new file mode 100644
index 000000000..404dcb7f3
--- /dev/null
+++ b/test/test-api-fill.c
@@ -0,0 +1,180 @@
+/* ----------------------------------------------------------------------------
+Copyright (c) 2018-2020, Microsoft Research, Daan Leijen
+This is free software; you can redistribute it and/or modify it under the
+terms of the MIT license. A copy of the license can be found in the file
+"LICENSE" at the root of this distribution.
+-----------------------------------------------------------------------------*/
+#include "mimalloc.h"
+#include "mimalloc-types.h"
+
+#include "testhelper.h"
+
+// ---------------------------------------------------------------------------
+// Helper functions
+// ---------------------------------------------------------------------------
+bool check_zero_init(uint8_t* p, size_t size);
+
+// ---------------------------------------------------------------------------
+// Main testing
+// ---------------------------------------------------------------------------
+int main(void) {
+ mi_option_disable(mi_option_verbose);
+
+ // ---------------------------------------------------
+ // Zeroing allocation
+ // ---------------------------------------------------
+ CHECK_BODY("zeroinit-zalloc-small", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
+ result = check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-zalloc-large", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
+ result = check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-zalloc_small", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_zalloc_small(zalloc_size);
+ result = check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("zeroinit-calloc-small", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
+ result = check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-calloc-large", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
+ result = check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("zeroinit-rezalloc-small", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
+ result = check_zero_init(p, zalloc_size);
+ zalloc_size *= 3;
+ p = (uint8_t*)mi_rezalloc(p, zalloc_size);
+ result &= check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-rezalloc-large", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_zalloc(zalloc_size);
+ result = check_zero_init(p, zalloc_size);
+ zalloc_size *= 3;
+ p = (uint8_t*)mi_rezalloc(p, zalloc_size);
+ result &= check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("zeroinit-recalloc-small", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
+ result = check_zero_init(p, calloc_size);
+ calloc_size *= 3;
+ p = (uint8_t*)mi_recalloc(p, calloc_size, 1);
+ result &= check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-recalloc-large", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_calloc(calloc_size, 1);
+ result = check_zero_init(p, calloc_size);
+ calloc_size *= 3;
+ p = (uint8_t*)mi_recalloc(p, calloc_size, 1);
+ result &= check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+
+ // ---------------------------------------------------
+ // Zeroing in aligned API
+ // ---------------------------------------------------
+ CHECK_BODY("zeroinit-zalloc_aligned-small", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-zalloc_aligned-large", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("zeroinit-calloc_aligned-small", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-calloc_aligned-large", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("zeroinit-rezalloc_aligned-small", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, zalloc_size);
+ zalloc_size *= 3;
+ p = (uint8_t*)mi_rezalloc_aligned(p, zalloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result &= check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-rezalloc_aligned-large", {
+ size_t zalloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, zalloc_size);
+ zalloc_size *= 3;
+ p = (uint8_t*)mi_rezalloc_aligned(p, zalloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result &= check_zero_init(p, zalloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("zeroinit-recalloc_aligned-small", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, calloc_size);
+ calloc_size *= 3;
+ p = (uint8_t*)mi_recalloc_aligned(p, calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
+ result &= check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("zeroinit-recalloc_aligned-large", {
+ size_t calloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_calloc_aligned(calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
+ result = check_zero_init(p, calloc_size);
+ calloc_size *= 3;
+ p = (uint8_t*)mi_recalloc_aligned(p, calloc_size, 1, MI_MAX_ALIGN_SIZE * 2);
+ result &= check_zero_init(p, calloc_size);
+ mi_free(p);
+ });
+
+ // ---------------------------------------------------
+ // Done
+ // ---------------------------------------------------[]
+ return print_test_summary();
+}
+
+// ---------------------------------------------------------------------------
+// Helper functions
+// ---------------------------------------------------------------------------
+bool check_zero_init(uint8_t* p, size_t size) {
+ if(!p)
+ return false;
+ bool result = true;
+ for (size_t i = 0; i < size; ++i) {
+ result &= p[i] == 0;
+ }
+ return result;
+}
From 1cf7ca021da6535df41746b3d9445571c7a0ebc2 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 21:56:52 +0100
Subject: [PATCH 059/131] Add tests for debug mode "uninit fill" behaviour
---
test/test-api-fill.c | 124 +++++++++++++++++++++++++++++++++++++++++++
test/test-api.c | 1 +
2 files changed, 125 insertions(+)
diff --git a/test/test-api-fill.c b/test/test-api-fill.c
index 404dcb7f3..39f6f8815 100644
--- a/test/test-api-fill.c
+++ b/test/test-api-fill.c
@@ -13,6 +13,9 @@ terms of the MIT license. A copy of the license can be found in the file
// Helper functions
// ---------------------------------------------------------------------------
bool check_zero_init(uint8_t* p, size_t size);
+#if MI_DEBUG >= 2
+bool check_debug_fill_uninit(uint8_t* p, size_t size);
+#endif
// ---------------------------------------------------------------------------
// Main testing
@@ -160,6 +163,114 @@ int main(void) {
mi_free(p);
});
+#if MI_DEBUG >= 2
+ // ---------------------------------------------------
+ // Debug filling
+ // ---------------------------------------------------
+ CHECK_BODY("uninit-malloc-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("uninit-malloc-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("uninit-malloc_small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_malloc_small(malloc_size);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("uninit-realloc-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
+ result = check_debug_fill_uninit(p, malloc_size);
+ malloc_size *= 3;
+ p = (uint8_t*)mi_realloc(p, malloc_size);
+ result &= check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("uninit-realloc-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
+ result = check_debug_fill_uninit(p, malloc_size);
+ malloc_size *= 3;
+ p = (uint8_t*)mi_realloc(p, malloc_size);
+ result &= check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("uninit-mallocn-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("uninit-mallocn-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("uninit-reallocn-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
+ result = check_debug_fill_uninit(p, malloc_size);
+ malloc_size *= 3;
+ p = (uint8_t*)mi_reallocn(p, malloc_size, 1);
+ result &= check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("uninit-reallocn-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_mallocn(malloc_size, 1);
+ result = check_debug_fill_uninit(p, malloc_size);
+ malloc_size *= 3;
+ p = (uint8_t*)mi_reallocn(p, malloc_size, 1);
+ result &= check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("uninit-malloc_aligned-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("uninit-malloc_aligned-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+
+ CHECK_BODY("uninit-realloc_aligned-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_debug_fill_uninit(p, malloc_size);
+ malloc_size *= 3;
+ p = (uint8_t*)mi_realloc_aligned(p, malloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result &= check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+ CHECK_BODY("uninit-realloc_aligned-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_malloc_aligned(malloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result = check_debug_fill_uninit(p, malloc_size);
+ malloc_size *= 3;
+ p = (uint8_t*)mi_realloc_aligned(p, malloc_size, MI_MAX_ALIGN_SIZE * 2);
+ result &= check_debug_fill_uninit(p, malloc_size);
+ mi_free(p);
+ });
+#endif
+
// ---------------------------------------------------
// Done
// ---------------------------------------------------[]
@@ -178,3 +289,16 @@ bool check_zero_init(uint8_t* p, size_t size) {
}
return result;
}
+
+#if MI_DEBUG >= 2
+bool check_debug_fill_uninit(uint8_t* p, size_t size) {
+ if(!p)
+ return false;
+
+ bool result = true;
+ for (size_t i = 0; i < size; ++i) {
+ result &= p[i] == MI_DEBUG_UNINIT;
+ }
+ return result;
+}
+#endif
diff --git a/test/test-api.c b/test/test-api.c
index 8ecd31a18..7ce6f1119 100644
--- a/test/test-api.c
+++ b/test/test-api.c
@@ -34,6 +34,7 @@ we therefore test the API over various inputs. Please add more tests :-)
#include "mimalloc.h"
// #include "mimalloc-internal.h"
+#include "mimalloc-types.h" // for MI_DEBUG
#include "testhelper.h"
From 691eb0d8edc17fbb4850a704244fed302282f931 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 19 Dec 2021 21:57:06 +0100
Subject: [PATCH 060/131] Add tests to check "freed memory fill" behaviour in
debug mode
---
test/test-api-fill.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/test/test-api-fill.c b/test/test-api-fill.c
index 39f6f8815..0e5a65dc7 100644
--- a/test/test-api-fill.c
+++ b/test/test-api-fill.c
@@ -15,6 +15,7 @@ terms of the MIT license. A copy of the license can be found in the file
bool check_zero_init(uint8_t* p, size_t size);
#if MI_DEBUG >= 2
bool check_debug_fill_uninit(uint8_t* p, size_t size);
+bool check_debug_fill_freed(uint8_t* p, size_t size);
#endif
// ---------------------------------------------------------------------------
@@ -269,6 +270,22 @@ int main(void) {
result &= check_debug_fill_uninit(p, malloc_size);
mi_free(p);
});
+
+
+ CHECK_BODY("fill-freed-small", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX / 2;
+ uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
+ mi_free(p);
+ // First sizeof(void*) bytes will contain housekeeping data, skip these
+ result = check_debug_fill_freed(p + sizeof(void*), malloc_size - sizeof(void*));
+ });
+ CHECK_BODY("fill-freed-large", {
+ size_t malloc_size = MI_SMALL_SIZE_MAX * 2;
+ uint8_t* p = (uint8_t*)mi_malloc(malloc_size);
+ mi_free(p);
+ // First sizeof(void*) bytes will contain housekeeping data, skip these
+ result = check_debug_fill_freed(p + sizeof(void*), malloc_size - sizeof(void*));
+ });
#endif
// ---------------------------------------------------
@@ -301,4 +318,15 @@ bool check_debug_fill_uninit(uint8_t* p, size_t size) {
}
return result;
}
+
+bool check_debug_fill_freed(uint8_t* p, size_t size) {
+ if(!p)
+ return false;
+
+ bool result = true;
+ for (size_t i = 0; i < size; ++i) {
+ result &= p[i] == MI_DEBUG_FREED;
+ }
+ return result;
+}
#endif
From 164b3a9667f472367f84851cfabc87ab08df26f6 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Tue, 21 Dec 2021 13:07:39 +0100
Subject: [PATCH 061/131] Pass build config to CMake invocation in Windows
pipeline jobs
---
azure-pipelines.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 8bd51ab04..cfaf1876a 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -43,7 +43,7 @@ jobs:
solution: $(BuildType)/libmimalloc.sln
configuration: '$(MSBuildConfiguration)'
msbuildArguments: -m
- - script: ctest --verbose --timeout 120
+ - script: ctest --verbose --timeout 120 -C $(MSBuildConfiguration)
workingDirectory: $(BuildType)
displayName: CTest
#- script: $(BuildType)\$(BuildType)\mimalloc-test-stress
From 3d91c0e73717a8da64c4edbf08066e2d7cd506eb Mon Sep 17 00:00:00 2001
From: akarin
Date: Sun, 26 Dec 2021 18:17:53 +0900
Subject: [PATCH 062/131] cmake: export mimalloc-static as well
Otherwise a static only build would not be usable as cmake package
(as mimalloc.cmake wouldn't be generated).
Signed-off-by: akarin
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 87f4cddde..93686cef5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -330,6 +330,7 @@ if (MI_BUILD_STATIC)
endif()
install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY)
+ install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif()
# install include files
From 43e5cd2671585023d425f247b5c39cfa1207866a Mon Sep 17 00:00:00 2001
From: daan
Date: Sat, 1 Jan 2022 15:54:06 -0800
Subject: [PATCH 063/131] revise assembly test for the _mi_threadid(); fix
issue #495 with musl libc on arm; test specifically for bionic libc on
Android
---
include/mimalloc-internal.h | 122 ++++++++++++++++++++----------------
1 file changed, 68 insertions(+), 54 deletions(-)
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index 06c3e95f5..5f0166406 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -698,8 +698,10 @@ static inline size_t _mi_os_numa_node_count(void) {
// -------------------------------------------------------------------
// Getting the thread id should be performant as it is called in the
// fast path of `_mi_free` and we specialize for various platforms.
+// We only require _mi_threadid() to return a unique id for each thread.
// -------------------------------------------------------------------
#if defined(_WIN32)
+
#define WIN32_LEAN_AND_MEAN
#include
static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept {
@@ -707,81 +709,93 @@ static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept {
return (uintptr_t)NtCurrentTeb();
}
-#elif defined(__GNUC__) && \
- (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__))
-
+// We use assembly for a fast thread id on the main platforms. The TLS layout depends on
+// both the OS and libc implementation so we use specific tests for each main platform.
+// If you test on another platform and it works please send a PR :-)
// see also https://akkadia.org/drepper/tls.pdf for more info on the TLS register.
+#elif defined(__GNUC__) && ( \
+ (defined(__GLIBC__) && (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))) \
+ || (defined(__APPLE__) && (defined(__x86_64__) || defined(__aarch64__))) \
+ || (defined(__BIONIC__) && (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))) \
+ || (defined(__FreeBSD__) && (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__))) \
+ )
+
static inline void* mi_tls_slot(size_t slot) mi_attr_noexcept {
void* res;
const size_t ofs = (slot*sizeof(void*));
-#if defined(__i386__)
- __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86 32-bit always uses GS
-#elif defined(__APPLE__) && defined(__x86_64__)
- __asm__("movq %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 macOSX uses GS
-#elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
- __asm__("movl %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x32 ABI
-#elif defined(__x86_64__)
- __asm__("movq %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 Linux, BSD uses FS
-#elif defined(__arm__) // arm32: defined but currently not used (see issue #495)
- void** tcb; MI_UNUSED(ofs);
- __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
- res = tcb[slot];
-#elif defined(__aarch64__)
- void** tcb; MI_UNUSED(ofs);
- #if defined(__APPLE__) // M1, issue #343
- __asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tcb));
- tcb = (void**)((uintptr_t)tcb & ~0x07UL); // clear lower 3 bits
- #else
- __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
+ #if defined(__i386__)
+ __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86 32-bit always uses GS
+ #elif defined(__APPLE__) && defined(__x86_64__)
+ __asm__("movq %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 macOSX uses GS
+ #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
+ __asm__("movl %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x32 ABI
+ #elif defined(__x86_64__)
+ __asm__("movq %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 Linux, BSD uses FS
+ #elif defined(__arm__)
+ void** tcb; MI_UNUSED(ofs);
+ __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
+ res = tcb[slot];
+ #elif defined(__aarch64__)
+ void** tcb; MI_UNUSED(ofs);
+ #if defined(__APPLE__) // M1, issue #343
+ __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb));
+ #else
+ __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
+ #endif
+ res = tcb[slot];
#endif
- res = tcb[slot];
-#endif
return res;
}
-// setting a tls slot is only used on macOSX for now
+// setting a tls slot is only used on macOS for now
static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept {
const size_t ofs = (slot*sizeof(void*));
-#if defined(__i386__)
- __asm__("movl %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // 32-bit always uses GS
-#elif defined(__APPLE__) && defined(__x86_64__)
- __asm__("movq %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 macOSX uses GS
-#elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
- __asm__("movl %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x32 ABI
-#elif defined(__x86_64__)
- __asm__("movq %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 Linux, BSD uses FS
-#elif defined(__arm__)
- void** tcb; MI_UNUSED(ofs);
- __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
- tcb[slot] = value;
-#elif defined(__aarch64__)
- void** tcb; MI_UNUSED(ofs);
- #if defined(__APPLE__) // M1, issue #343
- __asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tcb));
- tcb = (void**)((uintptr_t)tcb & ~0x07UL); // clear lower 3 bits
- #else
- __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
+ #if defined(__i386__)
+ __asm__("movl %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // 32-bit always uses GS
+ #elif defined(__APPLE__) && defined(__x86_64__)
+ __asm__("movq %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 macOS uses GS
+ #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
+ __asm__("movl %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x32 ABI
+ #elif defined(__x86_64__)
+ __asm__("movq %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 Linux, BSD uses FS
+ #elif defined(__arm__)
+ void** tcb; MI_UNUSED(ofs);
+ __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
+ tcb[slot] = value;
+ #elif defined(__aarch64__)
+ void** tcb; MI_UNUSED(ofs);
+ #if defined(__APPLE__) // M1, issue #343
+ __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb));
+ #else
+ __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
+ #endif
+ tcb[slot] = value;
#endif
- tcb[slot] = value;
-#endif
}
static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept {
-#if defined(__ANDROID__) && (defined(__arm__) || defined(__aarch64__))
- // issue #384, #495: on arm Android, slot 1 is the thread ID (pointer to pthread internal struct)
- return (uintptr_t)mi_tls_slot(1);
-#else
- // in all our other targets, slot 0 is the pointer to the thread control block
- return (uintptr_t)mi_tls_slot(0);
-#endif
+ #if defined(__BIONIC__)
+ // issue #384, #495: on the Bionic libc (Android), slot 1 is the thread id
+ // see: https://github.com/aosp-mirror/platform_bionic/blob/c44b1d0676ded732df4b3b21c5f798eacae93228/libc/platform/bionic/tls_defines.h#L86
+ return (uintptr_t)mi_tls_slot(1);
+ #else
+ // in all our other targets, slot 0 is the thread id
+ // glibc: https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/x86_64/nptl/tls.h
+ // apple: https://github.com/apple/darwin-xnu/blob/main/libsyscall/os/tsd.h#L36
+ return (uintptr_t)mi_tls_slot(0);
+ #endif
}
+
#else
-// otherwise use portable C
+
+// otherwise use portable C, taking the address of a thread local variable (this is still very fast on most platforms).
static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept {
return (uintptr_t)&_mi_heap_default;
}
+
#endif
+
// -----------------------------------------------------------------------
// Count bits: trailing or leading zeros (with MI_INTPTR_BITS on all zero)
// -----------------------------------------------------------------------
From d24262f4773ff3ef0308665c332107c5c01d3dcd Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Tue, 28 Dec 2021 14:54:15 +0100
Subject: [PATCH 064/131] Prefer MSVC 'data section magic' over C++ static
initialization
---
src/init.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/init.c b/src/init.c
index e06fa6b92..25de03018 100644
--- a/src/init.c
+++ b/src/init.c
@@ -557,20 +557,6 @@ static void mi_process_done(void) {
return TRUE;
}
-#elif defined(__cplusplus)
- // C++: use static initialization to detect process start
- static bool _mi_process_init(void) {
- mi_process_load();
- return (_mi_heap_main.thread_id != 0);
- }
- static bool mi_initialized = _mi_process_init();
-
-#elif defined(__GNUC__) || defined(__clang__)
- // GCC,Clang: use the constructor attribute
- static void __attribute__((constructor)) _mi_process_init(void) {
- mi_process_load();
- }
-
#elif defined(_MSC_VER)
// MSVC: use data section magic for static libraries
// See
@@ -586,9 +572,23 @@ static void mi_process_done(void) {
__pragma(comment(linker, "/include:" "__mi_msvc_initu"))
#endif
#pragma data_seg(".CRT$XIU")
- _crt_cb _mi_msvc_initu[] = { &_mi_process_init };
+ extern "C" _crt_cb _mi_msvc_initu[] = { &_mi_process_init };
#pragma data_seg()
+#elif defined(__cplusplus)
+ // C++: use static initialization to detect process start
+ static bool _mi_process_init(void) {
+ mi_process_load();
+ return (_mi_heap_main.thread_id != 0);
+ }
+ static bool mi_initialized = _mi_process_init();
+
+#elif defined(__GNUC__) || defined(__clang__)
+ // GCC,Clang: use the constructor attribute
+ static void __attribute__((constructor)) _mi_process_init(void) {
+ mi_process_load();
+ }
+
#else
#pragma message("define a way to call mi_process_load on your platform")
#endif
From f456bc75ead42e71680fc6d1111ffa16e85b1425 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Tue, 28 Dec 2021 14:59:32 +0100
Subject: [PATCH 065/131] Perform thread cleanup for main threads as late as
possible for Windows static builds
---
src/init.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/init.c b/src/init.c
index 25de03018..47aa2b23a 100644
--- a/src/init.c
+++ b/src/init.c
@@ -493,6 +493,11 @@ void mi_process_init(void) mi_attr_noexcept {
#endif
_mi_verbose_message("secure level: %d\n", MI_SECURE);
mi_thread_init();
+#if defined(_WIN32) && !defined(MI_SHARED_LIB)
+ // When building as a static lib FLS cleanup happens to early for the main thread.
+ // Make it a no-op and perform it explicitly later.
+ FlsSetValue(mi_fls_key, NULL);
+#endif
mi_stats_reset(); // only call stat reset *after* thread init (or the heap tld == NULL)
if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
@@ -522,6 +527,8 @@ static void mi_process_done(void) {
process_done = true;
#if defined(_WIN32) && !defined(MI_SHARED_LIB)
+ // Explicitly clean up main thread
+ _mi_thread_done(_mi_heap_default);
FlsSetValue(mi_fls_key, NULL); // don't call main-thread callback
FlsFree(mi_fls_key); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
#endif
From 2b1990805745dad1a7f85c5aa17c2d5dca7903a8 Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 2 Jan 2022 13:40:59 +0100
Subject: [PATCH 066/131] Expand comment on 'FLS early cleanup avoidance' in
mi_process_init()
---
src/init.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/init.c b/src/init.c
index 47aa2b23a..195191514 100644
--- a/src/init.c
+++ b/src/init.c
@@ -494,8 +494,11 @@ void mi_process_init(void) mi_attr_noexcept {
_mi_verbose_message("secure level: %d\n", MI_SECURE);
mi_thread_init();
#if defined(_WIN32) && !defined(MI_SHARED_LIB)
- // When building as a static lib FLS cleanup happens to early for the main thread.
- // Make it a no-op and perform it explicitly later.
+ /* When building as a static lib the FLS cleanup happens to early for the main thread.
+ * To avoid that set the FLS value for the main thread to NULL; the eventual
+ * mi_fls_done() execution won't call _mi_thread_done().
+ * The latter function is later called explicitly from mi_process_done().
+ * See GitHub issue #508 for more background and explanation. */
FlsSetValue(mi_fls_key, NULL);
#endif
mi_stats_reset(); // only call stat reset *after* thread init (or the heap tld == NULL)
@@ -527,7 +530,7 @@ static void mi_process_done(void) {
process_done = true;
#if defined(_WIN32) && !defined(MI_SHARED_LIB)
- // Explicitly clean up main thread
+ // Explicitly clean up main thread. See comment in mi_process_init() for reason
_mi_thread_done(_mi_heap_default);
FlsSetValue(mi_fls_key, NULL); // don't call main-thread callback
FlsFree(mi_fls_key); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
From 17762a7eb124a6dd43644166db985a3d2263c30b Mon Sep 17 00:00:00 2001
From: Frank Richter
Date: Sun, 2 Jan 2022 13:41:16 +0100
Subject: [PATCH 067/131] Remove a redundant FlsSetValue()
---
src/init.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/init.c b/src/init.c
index 195191514..ee347081a 100644
--- a/src/init.c
+++ b/src/init.c
@@ -532,7 +532,6 @@ static void mi_process_done(void) {
#if defined(_WIN32) && !defined(MI_SHARED_LIB)
// Explicitly clean up main thread. See comment in mi_process_init() for reason
_mi_thread_done(_mi_heap_default);
- FlsSetValue(mi_fls_key, NULL); // don't call main-thread callback
FlsFree(mi_fls_key); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
#endif
From d66ba0b95a0b8e9f1344993ac54fd6771335f636 Mon Sep 17 00:00:00 2001
From: Urs Hanselmann
Date: Wed, 5 Jan 2022 12:05:32 +0100
Subject: [PATCH 068/131] fix unused macro name for emscripten build
---
src/os.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/os.c b/src/os.c
index ee6e92c06..431c15ce3 100644
--- a/src/os.c
+++ b/src/os.c
@@ -638,11 +638,11 @@ static void* mi_os_mem_alloc(size_t size, size_t try_alignment, bool commit, boo
if (commit) flags |= MEM_COMMIT;
p = mi_win_virtual_alloc(NULL, size, try_alignment, flags, false, allow_large, is_large);
#elif defined(MI_USE_SBRK)
- KK_UNUSED(allow_large);
+ MI_UNUSED(allow_large);
*is_large = false;
p = mi_sbrk_heap_grow(size, try_alignment);
#elif defined(__wasi__)
- KK_UNUSED(allow_large);
+ MI_UNUSED(allow_large);
*is_large = false;
p = mi_wasm_heap_grow(size, try_alignment);
#else
From 0353fc38dd575903a9a2d80c9ddfff245d3c579f Mon Sep 17 00:00:00 2001
From: Christian Heimes
Date: Wed, 5 Jan 2022 13:11:44 +0100
Subject: [PATCH 069/131] Allow overrides of MI_DEBUG memory constants
CPython and Windows CRT debug builds use different values for uninit,
freed, and padding bytes. Make ``MI_DEBUG_*`` constants conditional to
allow embedders to override the constants.
Windows dbgheap:
```
_bNoMansLandFill = 0xFD
_bDeadLandFill = 0xDD
_bCleanLandFill = 0xCD
```
Python memory debug
```
PYMEM_CLEANBYTE 0xCD
PYMEM_DEADBYTE 0xDD
PYMEM_FORBIDDENBYTE 0xFD
```
Signed-off-by: Christian Heimes
---
include/mimalloc-types.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/mimalloc-types.h b/include/mimalloc-types.h
index b349dfc33..6eeffeb80 100644
--- a/include/mimalloc-types.h
+++ b/include/mimalloc-types.h
@@ -393,9 +393,15 @@ struct mi_heap_s {
// Debug
// ------------------------------------------------------
+#if !defined(MI_DEBUG_UNINIT)
#define MI_DEBUG_UNINIT (0xD0)
+#endif
+#if !defined(MI_DEBUG_FREED)
#define MI_DEBUG_FREED (0xDF)
+#endif
+#if !defined(MI_DEBUG_PADDING)
#define MI_DEBUG_PADDING (0xDE)
+#endif
#if (MI_DEBUG)
// use our own assertion to print without memory allocation
From 4b63c76861647332f0d18e9af360917cbc166182 Mon Sep 17 00:00:00 2001
From: Daan
Date: Mon, 10 Jan 2022 11:40:36 -0800
Subject: [PATCH 070/131] avoid conditional load on macos
---
include/mimalloc-internal.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index 5f0166406..3da9a0c8d 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -154,8 +154,8 @@ bool _mi_page_is_valid(mi_page_t* page);
// ------------------------------------------------------
#if defined(__GNUC__) || defined(__clang__)
-#define mi_unlikely(x) __builtin_expect((x),0)
-#define mi_likely(x) __builtin_expect((x),1)
+#define mi_unlikely(x) __builtin_expect(!!(x),false)
+#define mi_likely(x) __builtin_expect(!!(x),true)
#else
#define mi_unlikely(x) (x)
#define mi_likely(x) (x)
@@ -346,11 +346,15 @@ extern pthread_key_t _mi_heap_default_key;
// However, on the Apple M1 we do use the address of this variable as the unique thread-id (issue #356).
extern mi_decl_thread mi_heap_t* _mi_heap_default; // default heap to allocate from
-
static inline mi_heap_t* mi_get_default_heap(void) {
#if defined(MI_TLS_SLOT)
mi_heap_t* heap = (mi_heap_t*)mi_tls_slot(MI_TLS_SLOT);
- if (mi_unlikely(heap == NULL)) { heap = (mi_heap_t*)&_mi_heap_empty; } //_mi_heap_empty_get(); }
+ if (mi_unlikely(heap == NULL)) {
+ #ifdef __GNUC__
+ __asm(""); // prevent conditional load of the address of _mi_heap_empty
+ #endif
+ heap = (mi_heap_t*)&_mi_heap_empty;
+ }
return heap;
#elif defined(MI_TLS_PTHREAD_SLOT_OFS)
mi_heap_t* heap = *mi_tls_pthread_heap_slot();
From deda8bd22b11061a23748750654d1e71b9043652 Mon Sep 17 00:00:00 2001
From: Daan
Date: Mon, 10 Jan 2022 11:40:57 -0800
Subject: [PATCH 071/131] fix g++ compilation on macos
---
src/alloc-override-osx.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c
index 63297c4c9..af79d64a8 100644
--- a/src/alloc-override-osx.c
+++ b/src/alloc-override-osx.c
@@ -200,6 +200,9 @@ static malloc_introspection_t mi_introspect = {
};
static malloc_zone_t mi_malloc_zone = {
+ // note: even with designators, the order is important for C++ compilation
+ //.reserved1 = NULL,
+ //.reserved2 = NULL,
.size = &zone_size,
.malloc = &zone_malloc,
.calloc = &zone_calloc,
@@ -212,18 +215,20 @@ static malloc_zone_t mi_malloc_zone = {
.batch_free = &zone_batch_free,
.introspect = &mi_introspect,
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ #if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
+ .version = 10,
+ #else
+ .version = 9,
+ #endif
// switch to version 9+ on OSX 10.6 to support memalign.
.memalign = &zone_memalign,
.free_definite_size = &zone_free_definite_size,
.pressure_relief = &zone_pressure_relief,
- #if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ #if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
.claimed_address = &zone_claimed_address,
- .version = 10
- #else
- .version = 9
#endif
#else
- .version = 4
+ .version = 4,
#endif
};
From 1c9d853f39b3e5bcf2d830402a76de6c2db9bdd2 Mon Sep 17 00:00:00 2001
From: Daan
Date: Mon, 10 Jan 2022 12:00:24 -0800
Subject: [PATCH 072/131] nicefy
---
src/alloc-override-osx.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c
index af79d64a8..7e5c4e3e4 100644
--- a/src/alloc-override-osx.c
+++ b/src/alloc-override-osx.c
@@ -192,8 +192,7 @@ static malloc_introspection_t mi_introspect = {
.log = &intro_log,
.force_lock = &intro_force_lock,
.force_unlock = &intro_force_unlock,
-#if defined(MAC_OS_X_VERSION_10_6) && \
- MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
.statistics = &intro_statistics,
.zone_locked = &intro_zone_locked,
#endif
@@ -214,7 +213,7 @@ static malloc_zone_t mi_malloc_zone = {
.batch_malloc = &zone_batch_malloc,
.batch_free = &zone_batch_free,
.introspect = &mi_introspect,
-#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
.version = 10,
#else
@@ -421,8 +420,7 @@ __attribute__((constructor)) // seems not supported by g++-11 on the M1
static void _mi_macos_override_malloc() {
malloc_zone_t* purgeable_zone = NULL;
- #if defined(MAC_OS_X_VERSION_10_6) && \
- MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ #if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
// force the purgeable zone to exist to avoid strange bugs
if (malloc_default_purgeable_zone) {
purgeable_zone = malloc_default_purgeable_zone();
From 4fc63358a60b421c1d907f59cf19622661e14472 Mon Sep 17 00:00:00 2001
From: Daan
Date: Mon, 10 Jan 2022 12:01:26 -0800
Subject: [PATCH 073/131] update copyright year
---
include/mimalloc-internal.h | 2 +-
include/mimalloc.h | 2 +-
src/alloc-override-osx.c | 2 +-
src/alloc.c | 2 +-
src/init.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index 3da9a0c8d..b90595ba2 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
-Copyright (c) 2018-2021, Microsoft Research, Daan Leijen
+Copyright (c) 2018-2022, Microsoft Research, Daan Leijen
This is free software; you can redistribute it and/or modify it under the
terms of the MIT license. A copy of the license can be found in the file
"LICENSE" at the root of this distribution.
diff --git a/include/mimalloc.h b/include/mimalloc.h
index e7cbec11a..6f950751f 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
-Copyright (c) 2018-2021, Microsoft Research, Daan Leijen
+Copyright (c) 2018-2022, Microsoft Research, Daan Leijen
This is free software; you can redistribute it and/or modify it under the
terms of the MIT license. A copy of the license can be found in the file
"LICENSE" at the root of this distribution.
diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c
index 7e5c4e3e4..b53032e2e 100644
--- a/src/alloc-override-osx.c
+++ b/src/alloc-override-osx.c
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
-Copyright (c) 2018-2020, Microsoft Research, Daan Leijen
+Copyright (c) 2018-2022, Microsoft Research, Daan Leijen
This is free software; you can redistribute it and/or modify it under the
terms of the MIT license. A copy of the license can be found in the file
"LICENSE" at the root of this distribution.
diff --git a/src/alloc.c b/src/alloc.c
index ca32cabab..53dd59639 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
-Copyright (c) 2018-2021, Microsoft Research, Daan Leijen
+Copyright (c) 2018-2022, Microsoft Research, Daan Leijen
This is free software; you can redistribute it and/or modify it under the
terms of the MIT license. A copy of the license can be found in the file
"LICENSE" at the root of this distribution.
diff --git a/src/init.c b/src/init.c
index e06fa6b92..39a0d6fe2 100644
--- a/src/init.c
+++ b/src/init.c
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
-Copyright (c) 2018-2021, Microsoft Research, Daan Leijen
+Copyright (c) 2018-2022, Microsoft Research, Daan Leijen
This is free software; you can redistribute it and/or modify it under the
terms of the MIT license. A copy of the license can be found in the file
"LICENSE" at the root of this distribution.
From 397f44c9573d762364e6fe77d5dae16c2003489b Mon Sep 17 00:00:00 2001
From: Daan
Date: Mon, 10 Jan 2022 12:04:24 -0800
Subject: [PATCH 074/131] nicefy
---
src/alloc-override-osx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c
index b53032e2e..edd93b372 100644
--- a/src/alloc-override-osx.c
+++ b/src/alloc-override-osx.c
@@ -32,8 +32,7 @@ terms of the MIT license. A copy of the license can be found in the file
extern "C" {
#endif
-#if defined(MAC_OS_X_VERSION_10_6) && \
- MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
// only available from OSX 10.6
extern malloc_zone_t* malloc_default_purgeable_zone(void) __attribute__((weak_import));
#endif
From f317225a70929fea9be62e15945c2e8890cf6a1a Mon Sep 17 00:00:00 2001
From: Daan
Date: Mon, 10 Jan 2022 12:10:18 -0800
Subject: [PATCH 075/131] ignore reset_decommits option in the 2.x / dev-slice
version
---
include/mimalloc-internal.h | 2 +-
src/options.c | 2 +-
src/os.c | 15 +++++++--------
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index 348bef4ba..45775df4d 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -83,7 +83,7 @@ bool _mi_os_unprotect(void* addr, size_t size);
bool _mi_os_commit(void* addr, size_t size, bool* is_zero, mi_stats_t* stats);
bool _mi_os_decommit(void* p, size_t size, mi_stats_t* stats);
bool _mi_os_reset(void* p, size_t size, mi_stats_t* stats);
-bool _mi_os_unreset(void* p, size_t size, bool* is_zero, mi_stats_t* stats);
+// bool _mi_os_unreset(void* p, size_t size, bool* is_zero, mi_stats_t* stats);
size_t _mi_os_good_alloc_size(size_t size);
bool _mi_os_has_overcommit(void);
diff --git a/src/options.c b/src/options.c
index f7dbc6206..b8bac7501 100644
--- a/src/options.c
+++ b/src/options.c
@@ -72,7 +72,7 @@ static mi_option_desc_t options[_mi_option_last] =
{ 0, UNINIT, MI_OPTION(reset_decommits) }, // reset decommits memory
#else
{ 1, UNINIT, MI_OPTION(eager_region_commit) },
- { 0, UNINIT, MI_OPTION(reset_decommits) }, // reset uses MADV_FREE/MADV_DONTNEED
+ { 0, UNINIT, MI_OPTION(reset_decommits) }, // legacy; ignored now and reset always uses MADV_FREE/MADV_DONTNEED (issue #518)
#endif
{ 0, UNINIT, MI_OPTION(large_os_pages) }, // use large OS pages, use only with eager commit to prevent fragmentation of VMA's
{ 0, UNINIT, MI_OPTION(reserve_huge_os_pages) }, // per 1GiB huge pages
diff --git a/src/os.c b/src/os.c
index 8aac3845c..ac2d73d16 100644
--- a/src/os.c
+++ b/src/os.c
@@ -938,9 +938,12 @@ bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* tld_stats) {
return mi_os_commitx(addr, size, false, true /* conservative */, &is_zero, stats);
}
+/*
static bool mi_os_commit_unreset(void* addr, size_t size, bool* is_zero, mi_stats_t* stats) {
- return mi_os_commitx(addr, size, true, true /* conservative */, is_zero, stats);
+ return mi_os_commitx(addr, size, true, true // conservative
+ , is_zero, stats);
}
+*/
// Signal to the OS that the address range is no longer in use
// but may be used later again. This will release physical memory
@@ -1003,14 +1006,10 @@ static bool mi_os_resetx(void* addr, size_t size, bool reset, mi_stats_t* stats)
bool _mi_os_reset(void* addr, size_t size, mi_stats_t* tld_stats) {
MI_UNUSED(tld_stats);
mi_stats_t* stats = &_mi_stats_main;
- if (mi_option_is_enabled(mi_option_reset_decommits)) {
- return _mi_os_decommit(addr, size, stats);
- }
- else {
- return mi_os_resetx(addr, size, true, stats);
- }
+ return mi_os_resetx(addr, size, true, stats);
}
+/*
bool _mi_os_unreset(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stats) {
MI_UNUSED(tld_stats);
mi_stats_t* stats = &_mi_stats_main;
@@ -1022,7 +1021,7 @@ bool _mi_os_unreset(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stat
return mi_os_resetx(addr, size, false, stats);
}
}
-
+*/
// Protect a region in memory to be not accessible.
static bool mi_os_protectx(void* addr, size_t size, bool protect) {
From 8c50aa65eec76eff0684a0730b29247cff3644c0 Mon Sep 17 00:00:00 2001
From: daan
Date: Mon, 10 Jan 2022 15:26:22 -0800
Subject: [PATCH 076/131] fix warnings on Solaris, issue #520
---
src/os.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/os.c b/src/os.c
index c31df7570..4e0715b13 100644
--- a/src/os.c
+++ b/src/os.c
@@ -242,7 +242,7 @@ static void os_detect_overcommit(void) {
#if defined(__linux__)
int fd = open("/proc/sys/vm/overcommit_memory", O_RDONLY);
if (fd < 0) return;
- char buf[128];
+ char buf[32];
ssize_t nread = read(fd, &buf, sizeof(buf));
close(fd);
//
@@ -274,6 +274,17 @@ void _mi_os_init() {
#endif
+#if defined(MADV_NORMAL)
+static int mi_madvise(void* addr, size_t length, int advice) {
+ #if defined(__sun)
+ return madvise((caddr_t)addr, length, advice); // Solaris needs cast (issue #520)
+ #else
+ return madvise(addr, length, advice);
+ #endif
+}
+#endif
+
+
/* -----------------------------------------------------------
free memory
-------------------------------------------------------------- */
@@ -477,7 +488,7 @@ static void* mi_unix_mmapx(void* addr, size_t size, size_t try_alignment, int pr
}
#elif defined(MAP_ALIGN) // Solaris
if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) {
- void* p = mmap(try_alignment, size, protect_flags, flags | MAP_ALIGN, fd, 0);
+ void* p = mmap((void*)try_alignment, size, protect_flags, flags | MAP_ALIGN, fd, 0); // addr parameter is the required alignment
if (p!=MAP_FAILED) return p;
// fall back to regular mmap
}
@@ -589,7 +600,7 @@ static void* mi_unix_mmap(void* addr, size_t size, size_t try_alignment, int pro
// However, some systems only allow THP if called with explicit `madvise`, so
// when large OS pages are enabled for mimalloc, we call `madvise` anyways.
if (allow_large && use_large_os_page(size, try_alignment)) {
- if (madvise(p, size, MADV_HUGEPAGE) == 0) {
+ if (mi_madvise(p, size, MADV_HUGEPAGE) == 0) {
*is_large = true; // possibly
};
}
@@ -598,7 +609,7 @@ static void* mi_unix_mmap(void* addr, size_t size, size_t try_alignment, int pro
struct memcntl_mha cmd = {0};
cmd.mha_pagesize = large_os_page_size;
cmd.mha_cmd = MHA_MAPSIZE_VA;
- if (memcntl(p, size, MC_HAT_ADVISE, (caddr_t)&cmd, 0, 0) == 0) {
+ if (memcntl((caddr_t)p, size, MC_HAT_ADVISE, (caddr_t)&cmd, 0, 0) == 0) {
*is_large = true;
}
}
@@ -900,7 +911,7 @@ static bool mi_os_commitx(void* addr, size_t size, bool commit, bool conservativ
err = mprotect(start, csize, (PROT_READ | PROT_WRITE));
if (err != 0) { err = errno; }
//#if defined(MADV_FREE_REUSE)
- // while ((err = madvise(start, csize, MADV_FREE_REUSE)) != 0 && errno == EAGAIN) { errno = 0; }
+ // while ((err = mi_madvise(start, csize, MADV_FREE_REUSE)) != 0 && errno == EAGAIN) { errno = 0; }
//#endif
}
#else
@@ -966,16 +977,16 @@ static bool mi_os_resetx(void* addr, size_t size, bool reset, mi_stats_t* stats)
static _Atomic(size_t) advice = ATOMIC_VAR_INIT(MADV_FREE);
int oadvice = (int)mi_atomic_load_relaxed(&advice);
int err;
- while ((err = madvise(start, csize, oadvice)) != 0 && errno == EAGAIN) { errno = 0; };
+ while ((err = mi_madvise(start, csize, oadvice)) != 0 && errno == EAGAIN) { errno = 0; };
if (err != 0 && errno == EINVAL && oadvice == MADV_FREE) {
// if MADV_FREE is not supported, fall back to MADV_DONTNEED from now on
mi_atomic_store_release(&advice, (size_t)MADV_DONTNEED);
- err = madvise(start, csize, MADV_DONTNEED);
+ err = mi_madvise(start, csize, MADV_DONTNEED);
}
#elif defined(__wasi__)
int err = 0;
#else
- int err = madvise(start, csize, MADV_DONTNEED);
+ int err = mi_madvise(start, csize, MADV_DONTNEED);
#endif
if (err != 0) {
_mi_warning_message("madvise reset error: start: %p, csize: 0x%zx, errno: %i\n", start, csize, errno);
From 807a7ff08dc7bf160a8ae0d9f8d416ab3f096558 Mon Sep 17 00:00:00 2001
From: Daan Leijen
Date: Mon, 10 Jan 2022 15:39:49 -0800
Subject: [PATCH 077/131] improve commit/decommit on Linux
---
src/os.c | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/src/os.c b/src/os.c
index 4e0715b13..1939156c6 100644
--- a/src/os.c
+++ b/src/os.c
@@ -889,8 +889,7 @@ static bool mi_os_commitx(void* addr, size_t size, bool commit, bool conservativ
#if defined(_WIN32)
if (commit) {
- // if the memory was already committed, the call succeeds but it is not zero'd
- // *is_zero = true;
+ // *is_zero = true; // note: if the memory was already committed, the call succeeds but the memory is not zero'd
void* p = VirtualAlloc(start, csize, MEM_COMMIT, PAGE_READWRITE);
err = (p == start ? 0 : GetLastError());
}
@@ -900,23 +899,40 @@ static bool mi_os_commitx(void* addr, size_t size, bool commit, bool conservativ
}
#elif defined(__wasi__)
// WebAssembly guests can't control memory protection
- #elif defined(MAP_FIXED)
- if (!commit) {
- // use mmap with MAP_FIXED to discard the existing memory (and reduce commit charge)
- void* p = mmap(start, csize, PROT_NONE, (MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE), -1, 0);
+ #elif 0 && defined(MAP_FIXED) && !defined(__APPLE__)
+ // Linux: disabled for now as mmap fixed seems much more expensive than MADV_DONTNEED (and splits VMA's?)
+ if (commit) {
+ // commit: just change the protection
+ err = mprotect(start, csize, (PROT_READ | PROT_WRITE));
+ if (err != 0) { err = errno; }
+ }
+ else {
+ // decommit: use mmap with MAP_FIXED to discard the existing memory (and reduce rss)
+ const int fd = mi_unix_mmap_fd();
+ void* p = mmap(start, csize, PROT_NONE, (MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE), fd, 0);
if (p != start) { err = errno; }
}
- else {
- // for commit, just change the protection
+ #else
+ // Linux, macOSX and others.
+ if (commit) {
+ // commit: ensure we can access the area
err = mprotect(start, csize, (PROT_READ | PROT_WRITE));
if (err != 0) { err = errno; }
+ }
+ else {
+ #if defined(MADV_DONTNEED) && MI_DEBUG == 0 && MI_SECURE == 0
+ // decommit: use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE)
+ // (on the other hand, MADV_FREE would be good enough.. it is just not reflected in the stats :-( )
+ err = madvise(start, csize, MADV_DONTNEED);
+ #else
+ // decommit: just disable access (also used in debug and secure mode to trap on illegal access)
+ err = mprotect(start, csize, PROT_NONE);
+ if (err != 0) { err = errno; }
+ #endif
//#if defined(MADV_FREE_REUSE)
// while ((err = mi_madvise(start, csize, MADV_FREE_REUSE)) != 0 && errno == EAGAIN) { errno = 0; }
//#endif
}
- #else
- err = mprotect(start, csize, (commit ? (PROT_READ | PROT_WRITE) : PROT_NONE));
- if (err != 0) { err = errno; }
#endif
if (err != 0) {
_mi_warning_message("%s error: start: %p, csize: 0x%zx, err: %i\n", commit ? "commit" : "decommit", start, csize, err);
From 5bc9a1c95f5d058af707543b9220ed6e4156de15 Mon Sep 17 00:00:00 2001
From: Daan Leijen
Date: Mon, 10 Jan 2022 16:06:34 -0800
Subject: [PATCH 078/131] update redirection dll's for windows 11 (issue #498)
---
bin/mimalloc-redirect.dll | Bin 55808 -> 56832 bytes
bin/mimalloc-redirect.lib | Bin 2874 -> 2874 bytes
bin/mimalloc-redirect32.dll | Bin 39424 -> 40448 bytes
bin/mimalloc-redirect32.lib | Bin 2928 -> 2928 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/bin/mimalloc-redirect.dll b/bin/mimalloc-redirect.dll
index b7bf1d099681fc73d15ee8dd1b86a48de0aca1d1..83b6bd4f379ba4d9c0fcdf6b846c3b60867a31d1 100644
GIT binary patch
delta 7841
zcmb_heOOf0x?g+C$bcZ@2Qr|@3=BF7(g-T!2d6Pnx5~*;$*8Ob(}Y4C6%0-9j46qS
zD0Fp-bML8!4`KL{(J39R+ZoFgON~06vX7^xQ{6L!)p*P2TKAmG{jI&%VA1*W@I3GO
z{noqQ_g(LL*WPRIJvd(+;e2I8{Q@CyC~uLJacJMbme4o8u*_<>da6wBU-dl*e80N?
z)I&0UbE;g%u|5UAll!YnA1GnIhxFQM*2RQucs!DPasHEH!v8`fRX0i;olMq2p%rB9
zibFr%AEm1z%S(t07;#)HU1NE?r0QS)*
z#i_!3^aR?Eyq}6=g~Jge9Vb!<>Hj7Z%~*uWp*6)$_mPFPBv>chfg
zbX=4pMO*^2j9#hsjC3&HV3KO{4R&cR*!C&X-n;-k7F9I5cJYu+UF;5;5S@~=7K>(+
z8w+Yxt1(=V@!GQ5zJfYc9<@fNh{iO8kn$fb`Z&*&o@-C?b-K=;RaBMtA1BS$b$=g5rS0rw4smfTwSdGUP6Kk
zzZo2?_8(43q+1du#PSisMhIP%Fpa*P5VwkHtNj&;Kl6PXcS&&kRV)ny(U>oj%{QQC
z421044Xk7XCf1b)Ow1(i1XOgQHp#)~a}L(x&kEbms>wI#n4=DprTr|6
z4a|4vz|AboLs{TDm$NV{Su7Zex`0Q`GAuw?JqxR^_QzH0BYs_>cozR9#IN?#=d_dP
z|7jECwD;Y}k#ogf^R?yk>GGB7q@n59ttc;As!?U0`1KSnoK``jJcS&xV92u|>{;;h
z<
z>->I$lbPdB!nKM=5i@WU8mgqaCk#&Xg6}iCgZmBj=oH{auPUfjoTS>PWhDZRVga9G
zhIOhGHV5n*V2`ejcU?+%8t=N5ZZ_|Fl