logoalt Hacker News

deburoyesterday at 7:09 PM1 replyview on HN

Isn't using Arena just simplifying memory management, thereby reducing the amount of bugs as well?


Replies

Panzerschrekyesterday at 7:20 PM

Use-after-free bugs are still possible, if an allocated memory chunk outlives the arena instance used for it. With C++-style owning containers such kind of errors is possible too, but it's not so frequent.

But arenas can't be used in any case. They are suitable only if large amounts of allocations take place once and need to be deallocated all at once. If reallocation of freeing of individual memory chunks is needed, arenas can't be used, so, it's needed to manage each allocation individually, for which containers is a better choice compared to manual memory management.

show 2 replies