Skip to content

Commit

Permalink
Add comment warning against using page_allocator with GeneralPurposeA…
Browse files Browse the repository at this point in the history
…llocator

page_allocator + GeneralPurposeAllocator is a performance footgun

zigtools/zls#1128
  • Loading branch information
Jarred-Sumner authored Apr 18, 2023
1 parent 40e1fca commit fa0b866
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/std/heap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ fn rawCFree(

/// This allocator makes a syscall directly for every allocation and free.
/// Thread-safe and lock-free.
///
/// Using `page_allocator` with `GeneralPurposeAllocator` outside of WebAssembly is not recommended, as it causes detrimental performance issues in long-running programs.
pub const page_allocator = if (builtin.target.isWasm())
Allocator{
.ptr = undefined,
Expand Down

0 comments on commit fa0b866

Please sign in to comment.