mcpp index

compat.mimalloc

#include

mimalloc — compact general-purpose allocator with excellent performance

#include <mimalloc.h>
mcpp add compat.mimalloc@3.6.1

用法

来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。

// compat.mimalloc — assert the allocator is real, not just that it links.
//
// Every check below can fail: mi_usable_size reports what mimalloc actually
// reserved (so it proves the pointer came from mimalloc's own bookkeeping and
// not from a fallback), mi_zalloc must return zeroed memory, and a private
// heap must be able to hand out and destroy blocks independently of the
// default heap.
#include <mimalloc.h>
import std;

int main() {
    bool ok = true;

    auto check = [&](bool cond, std::string_view what) {
        if (!cond) {
            std::println("FAIL: {}", what);
            ok = false;
        }
    };

    // 1. Basic allocation, and mimalloc knows the block's real size.
    void* p = mi_malloc(1024);
// …

tests/examples/mimalloc/tests/alloc.cpp · 项目 tests/examples/mimalloc

openkal

目标结果环境测试项目首条诊断
aarch64-linux-muslrunsposixmimalloc
x86_64-linux-gnubuildsmimallocalloc ... FAIL (exit 139, 3.27s)
x86_64-linux-muslbuildsmimallocalloc ... FAIL (exit 139, 3.29s)
x86_64-windows-muslfailsmimallocerror: openkal-llvm-runtime is requested as '0.15.2' by mimalloc-tests, and the platform openkal-platform 0.32.1 is a version group

测量方式

2026-11-29 由 tests/openkal/compat.py 测得,使用 openkal-llvm-runtime 0.15.2、llvm@22.1.8、mcpp 2026.11.23.1。测试项目没有自行选择平台依赖。 上方徽章是所有已测目标里最严格那个的结果 —— 上表列出每个目标各自的环境。

构建

targets
mimalloc (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include

源文件 (44)

  • */src/alloc.c
  • */src/alloc-aligned.c
  • */src/alloc-posix.c
  • */src/arena.c
  • */src/arena-meta.c
  • */src/bitmap.c
  • */src/heap.c
  • */src/init.c
  • */src/libc.c
  • */src/options.c
  • */src/os.c
  • */src/page.c
  • */src/page-map.c
  • */src/random.c
  • */src/stats.c
  • */src/theap.c
  • */src/threadlocal.c
  • */src/prim/os.c
  • */src/prim/prim-tls.c
  • */src/util/libc.c
  • */src/util/options.c
  • */src/util/random.c
  • */src/util/stats.c
  • */src/util/threadlocal.c
  • */src/arena/arena.c
  • */src/arena/arena-alloc.c
  • */src/arena/arena-page.c
  • */src/arena/bitmap.c
  • */src/arena/bitmap-chunk.c
  • */src/alloc/alloc.c
  • */src/alloc/alloc-generic.c
  • */src/alloc/alloc-aligned.c
  • */src/alloc/alloc-posix.c
  • */src/alloc/page.c
  • */src/alloc/page-queue.c
  • */src/heap/heap.c
  • */src/heap/process.c
  • */src/heap/page-map.c
  • */src/heap/subproc.c
  • */src/heap/theap.c
  • */src/profile/sample-guarded.c
  • */src/profile/sample-profile.c
  • */src/profile/pprof.c
  • */src/prim/prim.c

版本

版本平台 镜像sha256
3.6.1 最新 LinuxWindowsmacOS CN GLOBAL 2672e6a99d45…
3.4.5 LinuxWindowsmacOS CN GLOBAL 19a43af0645c…