# Freeing memory allocated in a loop

**URL:** <https://ziggit.dev/t/freeing-memory-allocated-in-a-loop/13276>\
**Category:** Help\
**Tags:** memory-management\
**Created:** [November 29, 2025, 9:24pm UTC](https://ziggit.dev/t/freeing-memory-allocated-in-a-loop/13276 "2025-11-29T21:24:20Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [November 30, 2025, 12:43pm UTC](https://ziggit.dev/t/freeing-memory-allocated-in-a-loop/13276/14 "2025-11-30T12:43:03Z")

</div>

When the lifetime of container is the same with the lifetime of its elements, using an arena allocator for both the container and its elements is a much better solution.

In other words, freeing memory in `deinit` using `for` is a red flag that an arena allocator is a better fit.

---

_[View the full topic](https://ziggit.dev/t/freeing-memory-allocated-in-a-loop/13276)._
