---
title: withCapacity
framework: kernel
role: symbol
role_heading: Type Method
path: kernel/iobuffermemorydescriptor/1574841-withcapacity
---

# withCapacity

Creates a buffer memory descriptor and allocates enough bytes to meet the specified capacity.

## Declaration

```occ
static OSPtr<IOBufferMemoryDescriptor> withCapacity(vm_size_t capacity, IODirection withDirection, bool withContiguousMemory);
```

## Parameters

- `capacity`: The number of bytes to allocate.
- `withDirection`: The direction of the I/O transfer. For example: kIODirectionOut, kIODirectionIn.
- `withContiguousMemory`: A Boolean value that indicates whether to use a contiguous block of memory for the descriptor’s buffer.

## See Also

### Creating a Memory Buffer Descriptor

- [inTaskWithOptions](kernel/iobuffermemorydescriptor/1813824-intaskwithoptions.md)
- [inTaskWithOptions](kernel/iobuffermemorydescriptor/1574847-intaskwithoptions.md)
- [inTaskWithOptions](kernel/iobuffermemorydescriptor/3516446-intaskwithoptions.md)
- [inTaskWithPhysicalMask](kernel/iobuffermemorydescriptor/1813825-intaskwithphysicalmask.md)
- [inTaskWithPhysicalMask](kernel/iobuffermemorydescriptor/1574843-intaskwithphysicalmask.md)
- [initWithPhysicalMask](kernel/iobuffermemorydescriptor/1574833-initwithphysicalmask.md)
- [withOptions](kernel/iobuffermemorydescriptor/1574835-withoptions.md)
- [withBytes](kernel/iobuffermemorydescriptor/1574834-withbytes.md)
- [withCopy](kernel/iobuffermemorydescriptor/3074961-withcopy.md)
- [free](driverkit/iobuffermemorydescriptor/free.md)
