# Crash on oom strategy

**URL:** <https://ziggit.dev/t/crash-on-oom-strategy/18194>\
**Category:** Brainstorming\
**Created:** [November 3, 2026, 8:55am UTC](https://ziggit.dev/t/crash-on-oom-strategy/18194 "2026-11-03T08:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [November 3, 2026, 8:55am UTC](https://ziggit.dev/t/crash-on-oom-strategy/18194/1 "2026-11-03T08:55:57Z")

</div>

A program is (generally) unusable when it goes out of memory or some other lowlevel disaster happens.  
Would it make sense to crash these like this below?  
What are ways you people act on these?  
I am not talking about critical software but things like games etc.

```zig
pub const Fatal = enum {
    mem,
    // other disasters...
};

pub fn wtf(why: Fatal, sender: type, src: std.builtin.SourceLocation) noreturn {
    std.debug.panic("fatal error: {s} at {s}:{d} in {s}.{s}()", .{
        @tagName(why), src.file, src.line, @typeName(sender), src.fn_name,
    });
}

```

and

```zig
const xxx = gpa.alloc(...) catch wtf(mem, @This(), @src());

```

This would give a quick insight without needing an explicit stacktrace.

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [November 3, 2026, 9:23am UTC](https://ziggit.dev/t/crash-on-oom-strategy/18194/2 "2026-11-03T09:23:46Z")

</div>

> [@ericlang](#):
>
> This would give a quick insight without needing an explicit stacktrace.

it panics, which does provide a stacktrace (unless disabled); you may want to use `panicExtra(@returnAddress(), ...)` to exclude `wtf` from that trace.

But yeah, I do a similar thing in some CLI utils I wrote

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [November 3, 2026, 9:59am UTC](https://ziggit.dev/t/crash-on-oom-strategy/18194/3 "2026-11-03T09:59:00Z")

</div>

Ah yes. Excluding wtf from the stacktrace would be nice. I’ll check that. Thanks.

---

<div class="post-metadata">

**Author:** ![matklad](https://ziggit.dev/user_avatar/ziggit.dev/matklad/32/2462_2.png) [@matklad](https://ziggit.dev/u/matklad)\
**Post date:** [November 3, 2026, 10:22am UTC](https://ziggit.dev/t/crash-on-oom-strategy/18194/4 "2026-11-03T10:22:11Z")

</div>

I find the following utility useful:

```zig
pub fn oom(_: error{OutOfMemory}) noreturn {
    @panic("OOM");
}

```

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [November 3, 2026, 10:46am UTC](https://ziggit.dev/t/crash-on-oom-strategy/18194/5 "2026-11-03T10:46:28Z")

</div>

That is true. A dedicated one…  
I am still fighting with the logic of errorsets.
