---
title: withCapacity
framework: kernel
role: pseudoSymbol
path: kernel/iodataqueue/1811001-withcapacity
---

# withCapacity

Static method that creates a new IODataQueue instance with the capacity specified in the size parameter.

## Declaration

```occ
static IODataQueue *withCapacity(
 UInt32size); 
```

## Parameters

- `size`: The size of the data queue memory region.

## Return Value

Return Value Returns the newly allocated IODataQueue instance. Zero is returned on failure.

## Overview

Overview The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. This method allocates a new IODataQueue instance and then calls initWithCapacity() with the given size parameter. If the initWithCapacity() fails, the new instance is released and zero is returned.

## See Also

### Miscellaneous

- [enqueue](kernel/iodataqueue/1810927-enqueue.md)
- [getMemoryDescriptor](kernel/iodataqueue/1810939-getmemorydescriptor.md)
- [initWithCapacity](kernel/iodataqueue/1810950-initwithcapacity.md)
- [initWithEntries](kernel/iodataqueue/1810963-initwithentries.md)
- [sendDataAvailableNotification](kernel/iodataqueue/1810980-senddataavailablenotification.md)
- [setNotificationPort](kernel/iodataqueue/1810994-setnotificationport.md)
- [withEntries](kernel/iodataqueue/1811020-withentries.md)
