Basic Question on Allocation
ziggit.dev·3d
📊Financial advice
Preview
Report Post

January 19, 2026, 4:36am 1

This is perhaps too vague a question, but it’s on how to approach memory and such in Zig.

My background/understanding is we have the stack where we’d usually store transient state. However, some state must be dynamically allocated. This can be either when the alliocation amount is unknown or when the lifetime of a resource isn’t bound to function scope. Hence why there is malloc in C. Malloc is a general purpose purpose allocator handling requesting and tracking memory from the OS, so the idea with custom allocators is to have an allocator that suites your use case. However, I’ve been unable to wrap my mind on how to properly do that.

In my mind, I’m either going to go exact on memory or I’m going to at least have an upper bound. E.g., if my problem …

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help