[#2642] CompositeByteBuf.deallocate memory/GC improvement
Motivation: CompositeByteBuf.deallocate generates unnecessary GC pressure when using the 'foreach' loop, as a 'foreach' loop creates an iterator when looping. Modification: Convert 'foreach' loop into regular 'for' loop. Result: Less GC pressure (and possibly more throughput) as the 'for' loop does not create an iterator
This commit is contained in:
parent
33a810a513
commit
ac8ac59148
@ -1599,8 +1599,11 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf {
|
||||
}
|
||||
|
||||
freed = true;
|
||||
for (Component c: components) {
|
||||
c.freeIfNecessary();
|
||||
int size = components.size();
|
||||
// We're not using foreach to avoid creating an iterator.
|
||||
// see https://github.com/netty/netty/issues/2642
|
||||
for (int i = 0; i < size; i++) {
|
||||
components.get(i).freeIfNecessary();
|
||||
}
|
||||
|
||||
if (leak != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user