<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/MemoryLayout/size(ofValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s12MemoryLayoutOsRi_zRi0_zrlE4size7ofValueSix_tFZ"
  },
  "title" : "size(ofValue:)"
}
-->

# size(ofValue:)

Returns the contiguous memory footprint of the given instance.

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

## Parameters

`value`

A value representative of the type to describe.

## Return Value

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

## 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
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)