Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

Config

Public Struct
std.heap.debug_allocator.Config
pub const Config = struct

Fields

stack_trace_frames: usize = default_stack_trace_frames

Number of stack frames to capture.

enable_memory_limit: bool = false

If true, the allocator will have two fields:

  • total_requested_bytes which tracks the total allocated bytes of memory requested.
  • requested_memory_limit which causes allocations to return error.OutOfMemory when the total_requested_bytes exceeds this limit. If false, these fields will be void.
safety: bool = std.debug.runtime_safety

Whether to enable safety checks.

thread_safe: bool = !builtin.single_threaded

Whether the allocator may be used simultaneously from multiple threads.

never_unmap: bool = false

This is a temporary debugging trick you can use to turn segfaults into more helpful logged error messages with stack trace details. The downside is that every allocation will be leaked, unless used with retain_metadata!

retain_metadata: bool = false

This is a temporary debugging aid that retains metadata about allocations indefinitely. This allows a greater range of double frees to be reported. All metadata is freed when deinit is called. When used with never_unmap, deliberately leaked memory is also freed during deinit. Currently should be used with never_unmap to avoid segfaults. TODO https://github.com/ziglang/zig/issues/4298 will allow use without never_unmap

verbose_log: bool = false

Enables emitting info messages with the size and address of every allocation.

backing_allocator_zeroes: bool = true

Tell whether the backing allocator returns already-zeroed memory.

resize_stack_traces: bool = false

When resizing an allocation, refresh the stack trace with the resize callsite. Comes with a performance penalty.

canary: usize = @truncate(0x9232a6ff85dff10f)

Magic value that distinguishes allocations owned by this allocator from other regions of memory.

page_size: usize = default_page_size

The size of allocations requested from the backing allocator for subdividing into slots for small allocations.

Must be a power of two.

File

heap/debug_allocator.zig:112
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
pub const Config = struct {
    /// Number of stack frames to capture.
    stack_trace_frames: usize = default_stack_trace_frames,

    /// If true, the allocator will have two fields:
    ///  * `total_requested_bytes` which tracks the total allocated bytes of memory requested.
    ///  * `requested_memory_limit` which causes allocations to return `error.OutOfMemory`
    ///    when the `total_requested_bytes` exceeds this limit.
    /// If false, these fields will be `void`.
    enable_memory_limit: bool = false,

    /// Whether to enable safety checks.
    safety: bool = std.debug.runtime_safety,

    /// Whether the allocator may be used simultaneously from multiple threads.
    thread_safe: bool = !builtin.single_threaded,

    /// This is a temporary debugging trick you can use to turn segfaults into more helpful
    /// logged error messages with stack trace details. The downside is that every allocation
    /// will be leaked, unless used with retain_metadata!
    never_unmap: bool = false,

    /// This is a temporary debugging aid that retains metadata about allocations indefinitely.
    /// This allows a greater range of double frees to be reported. All metadata is freed when
    /// deinit is called. When used with never_unmap, deliberately leaked memory is also freed
    /// during deinit. Currently should be used with never_unmap to avoid segfaults.
    /// TODO https://github.com/ziglang/zig/issues/4298 will allow use without never_unmap
    retain_metadata: bool = false,

    /// Enables emitting info messages with the size and address of every allocation.
    verbose_log: bool = false,

    /// Tell whether the backing allocator returns already-zeroed memory.
    backing_allocator_zeroes: bool = true,

    /// When resizing an allocation, refresh the stack trace with the resize
    /// callsite. Comes with a performance penalty.
    resize_stack_traces: bool = false,

    /// Magic value that distinguishes allocations owned by this allocator from
    /// other regions of memory.
    canary: usize = @truncate(0x9232a6ff85dff10f),

    /// The size of allocations requested from the backing allocator for
    /// subdividing into slots for small allocations.
    ///
    /// Must be a power of two.
    page_size: usize = default_page_size,
}