So I am loading quite complex configuration where I don’t want to keep full configuration source loaded due to its size and lifetime (easily months or even years), so I need to copy some strings and construct some other non-u8 slices. I am using ArrayLists for creation these slices and their size is not easily determined in advance and later I do .toOwnedSlice.
So during init/deinit of this structure I do tens of different allocations of same lifetime, so If I want to use gpa I have to keep track of every single one. This seems like the perfect use case for arena. But I am reluctant to use it because it is a bump allocator and probably will leave some bytes in the middle due to the intermediate ArrayLists reallocations. And then there will also be some bytes left unused at the end because I believe arena preallocates some size in advance. So because I can’t do something like ArrayList.shrinkToLen on arena, leaving those unused bytes for months/years feels wasteful. But using gpa just feels like the wrong tool here. Any advice on how to apporach this?