# \[ANN\] ArrayAllocators.jl: Integrating calloc and aligned memory into Array construction

**URL:** <https://discourse.julialang.org/t/ann-arrayallocators-jl-integrating-calloc-and-aligned-memory-into-array-construction/80356>\
**Category:** Package Announcements\
**Tags:** package, announcement, array, zeros\
**Created:** [May 2, 2022, 7:32am UTC](https://discourse.julialang.org/t/ann-arrayallocators-jl-integrating-calloc-and-aligned-memory-into-array-construction/80356 "2022-05-02T07:32:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [May 4, 2022, 8:15pm UTC](https://discourse.julialang.org/t/ann-arrayallocators-jl-integrating-calloc-and-aligned-memory-into-array-construction/80356/3 "2022-05-04T20:15:09Z")

</div>

I apologize beforehand if my question is very naive. I’m one of those people who use Julia because they really don’t want to worry about internals.

I was told in [another thread](https://discourse.julialang.org/t/reinterpretedarray-performance-even-worse-on-1-8/80102/27) that Julia arrays are not guaranteed to be contiguous in memory. In particular - as a consequence - if I create a Julia array e.g. `Vector{UInt8}(undef, 8*N)` and then extract the pointer, then create a new `Vector{Float64}` that points to the same memory, then this is unsafe. Something like this:

```julia
_C = zeros(UInt8, 100 * sizeof(Float64))
ptr = Base.unsafe_convert(Ptr{Float64}, _C)
C = Base.unsafe_wrap(Array, ptr, 100)

```

(note that I’m proposing to remember `_C` so that the GC doesn’t release the memory.)

Now, if I were to use your `Vector{UInt8}(calloc, 8*N)` instead, i.e.,

```nohighlight
_C = Vector{UInt8}(calloc, 100 * sizeof(Float64))

```

is it guaranteed that the block of memory to which this vector points is contiguous? I.e. the procedure proposed above would be safe?

---

_[View the full topic](https://discourse.julialang.org/t/ann-arrayallocators-jl-integrating-calloc-and-aligned-memory-into-array-construction/80356)._
