Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't see this as very well conceived article, since the two concepts being discussed, manual memory management, and arena allocators are really orthogonal.

Arena allocators aren't going to save you from memory management bugs, and aren't intended to. They are just an efficient may to allocate and free a bunch of chunks of memory that have the same lifetime, for example due to belonging to the same data structure. The idea is that you just sequentially allocate from a large chunk of memory, then free up the entire large chunk in one go at the end of the collective lifetime of the allocated pieces.

The things that make memory management in C error-prone are that:

1) C doesn't have objects/destructors, so all freeing of memory is manual, thereby creating the possibility that you mess it up.

2) C's pointers don't have ownership semantics, and therefore also doesn't have niceties like shared ownership (cf C++'s shared vs unique pointers). All ownership tracking is manual, giving you another chance to mess up.

The only think that is going to save you from memory management errors in C is programmer discipline and attention to detail.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: