---
title: setLength
framework: kernel
role: symbol
role_heading: Instance Method
path: kernel/iobuffermemorydescriptor/1574850-setlength
---

# setLength

Sets the length of the data in the buffer.

## Declaration

```occ
virtual void setLength(vm_size_t length);
```

## Parameters

- `length`: The new length of the buffer. This value must be less than or equal to the capacity of the buffer.

## Discussion

Discussion At creation time, the system sets the buffer’s length to its capacity. Use this method to indicate that there are fewer bytes in the buffer than the total overall capacity. For example, you might set the length to minimize the amount of data you transfer. This method doesn’t change the total capacity of the buffer. Changing the length of a buffer allows you to reuse a buffer for multiple transfers of different lengths.

## See Also

### Configuring the Descriptor

- [getCapacity](kernel/iobuffermemorydescriptor/1574844-getcapacity.md)
- [setDirection](kernel/iobuffermemorydescriptor/1574826-setdirection.md)
