---
title: "reserveCapacity(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/dictionary/reservecapacity(_:)"
---

# reserveCapacity(_:)

Reserves enough space to store the specified number of key-value pairs.

## Declaration

```swift
mutating func reserveCapacity(_ minimumCapacity: Int)
```

## Parameters

- `minimumCapacity`: The requested number of key-value pairs to store.

## Discussion

Discussion If you are adding a known number of key-value pairs to a dictionary, use this method to avoid multiple reallocations. This method ensures that the dictionary has unique, mutable, contiguous storage, with space allocated for at least the requested number of key-value pairs. Calling the reserveCapacity(_:) method on a dictionary with bridged storage triggers a copy to contiguous storage even if the existing storage has room to store minimumCapacity key-value pairs.

## See Also

### Adding Keys and Values

- [updateValue(_:forKey:)](swift/dictionary/updatevalue(_:forkey:).md)
