<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4ComputeCommandEncoder/setThreadgroupMemoryLength(_:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTL4ComputeCommandEncoder(im)setThreadgroupMemoryLength:atIndex:"
  },
  "title" : "setThreadgroupMemoryLength(_:index:)"
}
-->

# setThreadgroupMemoryLength(_:index:)

Configures the size of a threadgroup memory buffer for a threadgroup argument in the compute shader function.

```
func setThreadgroupMemoryLength(_ length: Int, index: Int)
```

## Parameters

`length`

The size of the threadgroup memory, in bytes. Use a multiple of `16` bytes.

`index`

An integer that corresponds to the index of the argument you annotate with attribute `[[threadgroup(index)]]`
in the shader function.

---

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)