# \[ANN\] AlignedAllocs.jl - lightweight cross-platform allocation of aligned memory

**URL:** <https://discourse.julialang.org/t/ann-alignedallocs-jl-lightweight-cross-platform-allocation-of-aligned-memory/126772>\
**Category:** Package Announcements\
**Tags:** package, announcement, memory-allocation, data-alignment\
**Created:** [March 10, 2025, 3:39pm UTC](https://discourse.julialang.org/t/ann-alignedallocs-jl-lightweight-cross-platform-allocation-of-aligned-memory/126772 "2025-03-10T15:39:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [March 10, 2025, 3:39pm UTC](https://discourse.julialang.org/t/ann-alignedallocs-jl-lightweight-cross-platform-allocation-of-aligned-memory/126772/1 "2025-03-10T15:39:18Z")

</div>

This is a very lightweight cross-platform package that exports two functions, each is an aligned memory allocator.

```julia
memalign(item_type, item_count [, byte_alignment]) 
    providing uninitialized memory

memalign_clear(item_type, item_count [, byte_alignment])
    providing zeroed memory

`byte_alignment` defaults to the local processor cache-line size.
   This value is determined once, at precompilation.

```

The [README.md](https://github.com/JeffreySarnoff/AlignedAllocs.jl/blob/v0.1.3/README.md) file gives good reasons to use this (especially with vectors that are not large, or when using SIMD), and provides some more technical details.

The package returns a DenseVector{T}. To use the package for matrix (or higher degree array) allocations, `reshape` the returned vector:

```julia
using AlignAllocs
vec = memalign_clear(Float32, 4096, 64);
mat = reshape(vec, (1024, 4));

```
