Skip to content

Commit

Permalink
Use PlatformDependent.threadLocalRandom() to reduce memory footprint (
Browse files Browse the repository at this point in the history
#13977)

Motivation:
Direct use of `io.netty.util.internal.ThreadLocalRandom` and
`j.u.c.ThreadLocalRandom` could cause a lot of memory waste.

Modifications:
Use `PlatformDependent.threadLocalRandom()`.

Result:
Reduced Memory footprint.
  • Loading branch information
jchrys authored Apr 15, 2024
1 parent 4d961d0 commit 0e436dd
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.netty.util.internal.MathUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.ThreadLocalRandom;

import java.util.Random;

Expand Down Expand Up @@ -62,7 +61,7 @@ int nextId() {
}
} else if (freeIdx == -1 ||
// Let's make it somehow random which free slot is used.
ThreadLocalRandom.current().nextBoolean()) {
PlatformDependent.threadLocalRandom().nextBoolean()) {
// We have a slot that we can use to create a new bucket if we need to.
freeIdx = bucketIdx;
}
Expand Down

0 comments on commit 0e436dd

Please sign in to comment.