---
title: "alignment(ofValue:)"
framework: swift
role: symbol
role_heading: Type Method
path: "swift/memorylayout/alignment(ofvalue:)"
---

# alignment(ofValue:)

Returns the default memory alignment of T.

## Declaration

```swift
static func alignment(ofValue value: borrowing T) -> Int
```

## Parameters

- `value`: A value representative of the type to describe.

## Return Value

Return Value The default memory alignment, in bytes, of the given value’s type. This value is always positive.

## Discussion

Discussion Use a type’s alignment when allocating memory using an unsafe pointer. When you have a type instead of an instance, use the MemoryLayout<T>.stride static property instead. let x: Int = 100

// Finding the alignment of a value's type let s = MemoryLayout.alignment(ofValue: x) // s == 8

// Finding the alignment of a type directly let t = MemoryLayout<Int>.alignment // t == 8

## See Also

### Accessing the Layout of a Value

- [stride(ofValue:)](swift/memorylayout/stride(ofvalue:).md)
- [size(ofValue:)](swift/memorylayout/size(ofvalue:).md)
