HNNewShowAskJobs
Built with Tanstack Start
Defeating Memory Leaks with Zig Allocators(tgmatos.github.io)
15 points by gilgamesh3 2 days ago | 2 comments
  • pjmlp2 days 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++.

  • kingstnap2 days 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.