# Zig Gpa Allocator and Arrya Lists

**URL:** <https://ziggit.dev/t/zig-gpa-allocator-and-arrya-lists/12418>\
**Category:** Help\
**Tags:** language, memory-management\
**Created:** [October 9, 2025, 4:48am UTC](https://ziggit.dev/t/zig-gpa-allocator-and-arrya-lists/12418 "2025-10-09T04:48:15Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [October 10, 2025, 11:30am UTC](https://ziggit.dev/t/zig-gpa-allocator-and-arrya-lists/12418/7 "2025-10-10T11:30:12Z")

</div>

To clarify the upside that @floooh glossed over, being able to set some fields but leave others default can, depending on the type e.g. `ArrayList`, break the invariance of fields e.g. `ArrayList{.capacity = non_zero_number}` which causes `items` to be defaulted to a zero length slice which afaik has a pointer that’s `undefined`, using this will result in unchecked illegal and undefined behaviour.

So for `ArrayList`, and other types, default field values are unsafe to use, so it is recommended that fields with invariance do not get default values, preferring a declaration as an alternative. The addition of decl literals made this practice much nicer to use.

---

_[View the full topic](https://ziggit.dev/t/zig-gpa-allocator-and-arrya-lists/12418)._
