Clarifications regarding the Arena Allocator

Hello, so let’s say I happen to create 3 array list to do something in my program. Now, I don’t wanna have to defer ArrayList.deini() for each 3. So I decide to use an Arena Allocator and use that allocator for the 3 lists. Would just calling Arena.deinit() guarantee that the memory for all 3 of my ArrayList is freed? Or is it possible that moemory would be leaked and nothing would be picked up because Arena.deinit() was called?

Thank you :melting_face:

Yes, if you’re giving the arraylists the arena’s allocator(), you only need to deinit the arena.

Top tip - tests will detect leaks, so you can check this yourself!

1 Like

Alright… Thank you very much

Just be aware that using growing (and thus re-allocating) data structures with arenas can cause a lot of fragmentation and unusable memory space within the arena, it depends on your usage patterns and how and when those data structures grow / are resized.

If the arena is short lived this may not matter for your program.

1 Like

Oh okay then. Noted. Thank you