hey! how i can create a bytepacketbuilder with cus...
# ktor
g
hey! how i can create a bytepacketbuilder with custom capacity with ktor io?
a
Could you please explain what do you mean by capacity?
g
the capacity in the buffer that is passed in the second parameter of BytePacketBuilder, and its default capacity is 4096, i am getting this error when i try to write 8192 bytes
a
Could you please share a code snippet to reproduce
InsufficientSpaceException
?
In the Ktor 2.0.0, you can instantiate the
DefaultBufferPool
and pass it to the constructor of `BytePacketBuilder`:
Copy code
val pool = DefaultBufferPool(bufferSize = 1024 * 1024)
val builder = BytePacketBuilder(0, pool)
g
oh, thank you, i will use ktor 2.0.0, this is the code snippet that was causing the error, https://gist.github.com/gabrielleeg1/9621bd742c8753001f99fe76622aa1d2, the blockStates array have 8192 items
a
Thank you. My solution using Ktor 2.0.0 works for your case. Unfortunately, the
DefaultBufferPool
class is internal before Ktor 2.0.0.