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

# size(ofValue:)

Returns the contiguous memory footprint of the given instance.

## Declaration

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

## Parameters

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

## Return Value

Return Value The size, in bytes, of the given value’s type.

## Discussion

Discussion The result does not include any dynamically allocated or out of line storage. In particular, pointers and class instances all have the same contiguous memory footprint, regardless of the size of the referenced data. When you have a type instead of an instance, use the MemoryLayout<T>.size static property instead. let x: Int = 100

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

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

## See Also

### Accessing the Layout of a Value

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