Commit 8683f25d24

Andrew Kelley <andrew@ziglang.org>
2025-02-23 02:43:27
std.heap.DebugAllocator: default wasm to 64K page size
including on freestanding
1 parent dd54c48
Changed files (1)
lib
lib/std/heap/debug_allocator.zig
@@ -90,11 +90,16 @@ const mem = std.mem;
 const Allocator = std.mem.Allocator;
 const StackTrace = std.builtin.StackTrace;
 
-const default_page_size: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) {
-    .windows => 64 * 1024, // Makes `std.heap.PageAllocator` take the happy path.
-    .wasi => 64 * 1024, // Max alignment supported by `std.heap.WasmAllocator`.
-    else => 128 * 1024, // Avoids too many active mappings when `page_size_max` is low.
-});
+const default_page_size: usize = switch (builtin.os.tag) {
+    // Makes `std.heap.PageAllocator` take the happy path.
+    .windows => 64 * 1024,
+    else => switch (builtin.cpu.arch) {
+        // Max alignment supported by `std.heap.WasmAllocator`.
+        .wasm32, .wasm64 => 64 * 1024,
+        // Avoids too many active mappings when `page_size_max` is low.
+        else => @max(std.heap.page_size_max, 128 * 1024),
+    },
+};
 
 const Log2USize = std.math.Log2Int(usize);