Settings

Theme

Defeating Memory Leaks with Zig Allocators

tgmatos.github.io

16 points by gilgamesh3 6 months ago · 2 comments

Reader

pjmlp 6 months ago

Basically,

"CRT debug heap details"

https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-...

This is why I mention these new languages are expected to bring new tools, not recycle what we already have in C and C++.

kingstnap 6 months ago

> However, although the code seemed correct, the debug allocator reported memory leaks during executions

> This was an annoying memory leak, which I only discovered thanks to Zig's std.heap.debug_allocator.

> After identifying the leak, I tried to simply free the memory allocated in left and right, but doing so caused double free

Relevant: To be a better programmer, write little proofs in your head | https://news.ycombinator.com/item?id=44573409

When doing things with memory safety you should have obvious and clear memory allocations matched with deallocations that you prove to yourself are matched.

Just vibing memory lifetimes seems super jank.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection