Open tuhuynh27 opened 2 years ago
Same for String pool, we are converting byte[]
to String like below:
String str = new String(byteArray);
So every conversion, a new String object is allocated.
Reference: Avoid creating 'new' String objects when converting a byte[] to String using a specific charset
Doesn't Netty provide something similar like pooled buffer?
Oh yes @the123saurav Netty does have some utility for pooled object and buffer, we can utilize that
Issue: There is a lot of
byte[]
allocated when handling TCP messages:It's better to have a ByteArray pool allocator so that
byte[]
can be reused and avoid creating massive garbage for the GC and the throughput can be even better.For example: