Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public UnsafeDirectLittleEndian allocate(long size) {
}

public int getChunkSize() {
return allocator.chunkSize;
return allocator.chunkSize();
}

public long getHugeBufferSize() {
Expand Down Expand Up @@ -137,7 +137,6 @@ private class InnerAllocator extends PooledByteBufAllocator {

private final PoolArena<ByteBuffer>[] directArenas;
private final MemoryStatusThread statusThread;
private final int chunkSize;
Copy link
Contributor Author

@panbingkun panbingkun Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From code analysis, it seems that the chunkSize field here is useless. After the constructor is assigned, it is no longer used, and this value is directly derived from the parent class. So I suggest removing it.


public InnerAllocator() {
super(true);
Expand All @@ -150,8 +149,6 @@ public InnerAllocator() {
throw new RuntimeException("Failure while initializing allocator. Unable to retrieve direct arenas field.", e);
}

this.chunkSize = directArenas[0].chunkSize;

if (memoryLogger.isTraceEnabled()) {
statusThread = new MemoryStatusThread(this);
statusThread.start();
Expand All @@ -166,7 +163,7 @@ private UnsafeDirectLittleEndian newDirectBufferL(int initialCapacity, int maxCa

if (directArena != null) {

if (initialCapacity > directArena.chunkSize) {
if (initialCapacity > chunkSize()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of directArena.chunkSize is actually equal to chunkSize(), and it is a final.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. One final thing, I think chunkSize is deprecated in Netty? Is it possible to use the non-deprecated version?

// This is beyond chunk size so we'll allocate separately.
ByteBuf buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(initialCapacity, maxCapacity);

Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dep.junit.jupiter.version>5.10.1</dep.junit.jupiter.version>
<dep.slf4j.version>2.0.9</dep.slf4j.version>
<dep.guava-bom.version>32.1.3-jre</dep.guava-bom.version>
<dep.netty-bom.version>4.1.100.Final</dep.netty-bom.version>
<dep.netty-bom.version>4.1.104.Final</dep.netty-bom.version>
<dep.grpc-bom.version>1.60.0</dep.grpc-bom.version>
<dep.protobuf-bom.version>3.23.1</dep.protobuf-bom.version>
<dep.jackson-bom.version>2.16.0</dep.jackson-bom.version>
Expand Down