# \[ANN\] FixedSizeArrays.jl: What Array probably should have been

**URL:** https://discourse.julialang.org/t/ann-fixedsizearrays-jl-what-array-probably-should-have-been/129724
**Category:** Package Announcements
**Tags:** announcement, arrays
**Created:** [June 7, 2025, 4:45pm UTC](https://discourse.julialang.org/t/ann-fixedsizearrays-jl-what-array-probably-should-have-been/129724 "2025-06-07T16:45:43Z")
**Posts on this page:** 1
**Showing post:** 37

<div class="post-metadata">

### Author: ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)
#### Post date: [June 10, 2025, 10:12am UTC](https://discourse.julialang.org/t/ann-fixedsizearrays-jl-what-array-probably-should-have-been/129724/37 "2025-06-10T10:12:30Z")

</div>

Can you elaborate on the reasons for your decision to do

```julia
struct FixedSizeArray{T,N,Mem<:DenseVector{T}} <: DenseArray{T,N}
    mem::Mem
    size::NTuple{N,Int}
end

```

as opposed to

```julia
mutable struct AlternativeFixedSizeArray{T,N,Mem<:DenseVector{T}} <: DenseArray{T,N}
    const mem::Mem
    const size::NTuple{N,Int}
end

```

Both inform the compiler that the fields are constant (which allows the all-important LICM). The main difference is that the wrapper `AlternativeFixedSizeArray` is always heap-allocated (and it has an identity), while `FixedSizeArray` tries to be stack/register allocated.

Stack/register allocation is of course nice if you have many short-lived FixedSizeArrays that are backed by longer-living Memory instances. But I don’t see this happening in real life.

Since Memory is already heap-allocated, and since most uses will presumably have the same lifetime as the backing Memory instance, you don’t save a lot of allocs/memory. But you potentially lose a lot of perf – stuff needs to always be spilled to the stack, possible boxing-unboxing conversions, etc.

PS. The trade-offs are very different for e.g. array views! These _are_ typically short-lived, and re-use longer lived backing / parent memory instances. So views _must_ be `struct` instead of `mutable struct`.

---

_[View the full topic](https://discourse.julialang.org/t/ann-fixedsizearrays-jl-what-array-probably-should-have-been/129724)._
