allocateByteBuffer

Allocates a new standard (heap-backed) ByteBuffer with a capacity equal to this Kapacity.

This buffer is allocated on the JVM heap and will be managed by the standard garbage collector. It is backed by a standard ByteArray, which can be accessed via buffer.array().

Warning on Bounds: Because ByteBuffer capacities are strictly indexed by Int, the maximum allowed size is Int.MAX_VALUE- 8 (approximately 2.14 GB). If this capacity exceeds that limit, the resulting buffer size will be safely truncated to Int.MAX_VALUE to prevent memory allocation crashes.

Return

A new, empty ByteBuffer ready for writing.