Earlier quoted context omitted.
Yes. Hence the word 'joke' I used. For short running programs, it's fine. The longer running programs you can often find a few places where 95% of the leaks happen and easily 'free' those leaving the last 5% to leak slowly. It depends. Just remember it's a valid solution sometimes.
I still don't understand. The joke and the sometimes valid solution are different strategies . The joke only reminds people of the valid solution. It feels like multiple people are giving the article the briefest skim and assuming the two are the same. Perhaps focusing on the words "optional to call free" and extrapolating off that without looking at the code or properly reading the rest of the text. Unless I'm badly…
Memory leak proof every C program
171–175 of 175 posts
Re: Memory leak proof every C program
#172Earlier quoted context omitted.
Yeah, I first came across this strategy as a performance optimization in something Jared Sumner wrote about Bun (which is written in Zig).
Link to devblog article/tweet?
Re: Memory leak proof every C program
#173Earlier quoted context omitted.
This is like going back to malloc and free but using array indices rather than pointers, and each type has a fixed-size heap. We did it in one Microsoft service because the very first .NET releases had slow GCs.
One could argue that pointers are just array indices, where the array is your whole address space, and you only get the one array for all your types.
Re: Memory leak proof every C program
#174Earlier quoted context omitted.
it's not funny, it's not obvious and it's wasting a lot of people's time. ha. ha. ha.
Its painfully obvious.
Re: Memory leak proof every C program
#175Earlier quoted context omitted.
it's not funny, it's not obvious and it's wasting a lot of people's time. ha. ha. ha.
It's quite obvious... "If you don’t call free, memory usage will increase over time, but technically, it’s not a leak."