Preallocating memory for a 3 dimensional array

Views might be what you need?

julia> A = ones(4, 4)
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0

julia> B = view(A, 1:2, 1:2)
2×2 view(::Matrix{Float64}, 1:2, 1:2) with eltype Float64:
 1.0  1.0
 1.0  1.0

julia> B * [1, 2] # B acts as 2x2 matrix
2-element Vector{Float64}:
 3.0
 3.0

julia> B[2, 2] = 9999 # But the underlying memory is shared with A
3

julia> A
4×4 Matrix{Float64}:
 1.0     1.0  1.0  1.0
 1.0  9999.0  1.0  1.0
 1.0     1.0  1.0  1.0
 1.0     1.0  1.0  1.0