Not cache SwappedByteBuf in AbstractByteBuf to reduce memory footprint.
Motivation: We should not cache the SwappedByteBuf in AbstractByteBuf to reduce the memory footprint. Modifications: Not cache the SwappedByteBuf. Result: Less memory footprint.
This commit is contained in:
parent
2537880e5d
commit
4ddb81f36f
@ -57,11 +57,8 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
||||
int writerIndex;
|
||||
private int markedReaderIndex;
|
||||
private int markedWriterIndex;
|
||||
|
||||
private int maxCapacity;
|
||||
|
||||
private SwappedByteBuf swappedBuf;
|
||||
|
||||
protected AbstractByteBuf(int maxCapacity) {
|
||||
if (maxCapacity < 0) {
|
||||
throw new IllegalArgumentException("maxCapacity: " + maxCapacity + " (expected: >= 0)");
|
||||
@ -313,12 +310,7 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
||||
if (endianness == order()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
SwappedByteBuf swappedBuf = this.swappedBuf;
|
||||
if (swappedBuf == null) {
|
||||
this.swappedBuf = swappedBuf = newSwappedByteBuf();
|
||||
}
|
||||
return swappedBuf;
|
||||
return newSwappedByteBuf();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ public abstract class AbstractPooledByteBufTest extends AbstractByteBufTest {
|
||||
|
||||
ByteBuf buf2 = newBuffer(capacity);
|
||||
|
||||
assertSame(unwrapIfNeeded(buf), unwrapIfNeeded(buf2));
|
||||
assertEquals(unwrapIfNeeded(buf), unwrapIfNeeded(buf2));
|
||||
|
||||
buf2.writeShort(1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user