Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions scripts/build/deps/mimalloc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ export const mimalloc: Dependency = {

// ─── Override behavior (global malloc replacement) ───
// The decision matrix:
// ASAN: always OFF — ASAN interceptors must see the real malloc.
// macOS: OFF — macOS's malloc zones are sufficient and overriding
// causes issues with system frameworks (SecureTransport, etc.)
// that have their own allocator expectations.
// Linux: ON — this is the main win. All malloc/free goes through
// mimalloc, including WebKit's bmalloc when it falls back
// to system malloc.
// ASAN: always OFF — ASAN interceptors must see the real malloc.
// macOS: OFF — macOS's malloc zones are sufficient and overriding
// causes issues with system frameworks (SecureTransport, etc.)
// that have their own allocator expectations.
// Linux: ON — this is the main win. All malloc/free goes through
// mimalloc, including WebKit's bmalloc when it falls back
// to system malloc.
// Windows: OFF — Bun links the static CRT and calls mi_* directly;
// dev3's alloc-override.c emits _expand/_msize/free which
// duplicate against libucrt(d) at link time.
if (cfg.asan) {
args.MI_TRACK_ASAN = "ON";
args.MI_OVERRIDE = "OFF";
Expand All @@ -83,9 +86,10 @@ export const mimalloc: Dependency = {
args.MI_OVERRIDE = "ON";
args.MI_OSX_ZONE = "OFF";
args.MI_OSX_INTERPOSE = "OFF";
} else if (cfg.windows) {
// mimalloc's *default* is ON, so this must be explicit.
args.MI_OVERRIDE = "OFF";
}
Comment thread
claude[bot] marked this conversation as resolved.
// Windows: use mimalloc's defaults (no override; Windows has its own
// mechanism via the static CRT we link).

if (cfg.debug) {
// Heavy debug checks: guard bytes, freed-memory poisoning, double-free
Expand Down
Loading