GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix direct memory OOM on low-core containers · netty/netty@cc1fdf1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • buffer/src
    • main/java/io/netty/buffer
      • AdaptivePoolingAllocator.java
    • test/java/io/netty/buffer
      • SizeClassedChunkCacheTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
@UnstableApi
8585
final class AdaptivePoolingAllocator {
8686
private static final int LOW_MEM_THRESHOLD = 512 * 1024 * 1024;
87-
private static final boolean IS_LOW_MEM = Runtime.getRuntime().maxMemory() <= LOW_MEM_THRESHOLD;
87+
private static final boolean IS_LOW_MEM = SystemPropertyUtil.getBoolean(
88+
"io.netty.allocator.lowMemory",
89+
Runtime.getRuntime().maxMemory() <= LOW_MEM_THRESHOLD);
8890

8991
/**
9092
* Whether the IS_LOW_MEM setting should disable thread-local magazines.
@@ -884,7 +886,7 @@ public boolean isEmpty() {
884886
static final class SharedSizeClassedChunkCache extends SizeClassedChunkCache {
885887
// Must exceed CHUNK_REUSE_QUEUE (the retention floor) to leave room for burst absorption.
886888
// TODO replace with an unbounded concurrent collection once available.
887-
private static final int SHARED_CACHE_CAPACITY = Math.max(128, CHUNK_REUSE_QUEUE * 2);
889+
private static final int SHARED_CACHE_CAPACITY = Math.max(16, CHUNK_REUSE_QUEUE * 2);
888890
private final Queue<SizeClassedChunk> queue;
889891
private final AtomicLong purgeBudget;
890892
private final ArrayList<SizeClassedChunk> deferredBuffer = new ArrayList<>();
Collapse file

‎buffer/src/test/java/io/netty/buffer/SizeClassedChunkCacheTest.java‎

Copy file name to clipboardExpand all lines: buffer/src/test/java/io/netty/buffer/SizeClassedChunkCacheTest.java
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,19 @@ void cacheSettlesAtRetentionFloorAfterBurstThreadLocal() {
352352
void cacheSettlesAfterBurstShared() {
353353
SizeClassedChunkCache cache = SizeClassedChunkCache.create(false);
354354

355-
int excess = 10;
355+
int crq = AdaptivePoolingAllocator.CHUNK_REUSE_QUEUE;
356+
int capacity = Math.max(16, crq * 2);
357+
int excess = Math.min(10, capacity - crq);
358+
assertTrue(excess > 0, "excess must be positive for the test to be meaningful");
356359
SizeClassedChunk workingSet = chunkWithCapacity();
357360
cache.offerChunk(workingSet);
358-
for (int i = 0; i < AdaptivePoolingAllocator.CHUNK_REUSE_QUEUE - 1; i++) {
361+
for (int i = 0; i < crq - 1; i++) {
359362
cache.offerChunk(chunkWithoutCapacity());
360363
}
361364
SizeClassedChunk[] excessChunks = new SizeClassedChunk[excess];
362365
for (int i = 0; i < excess; i++) {
363366
excessChunks[i] = fullChunk();
364-
cache.offerChunk(excessChunks[i]);
367+
assertTrue(cache.offerChunk(excessChunks[i]), "all excess chunks must be accepted by the queue");
365368
}
366369

367370
int maxCycles = (AdaptivePoolingAllocator.CHUNK_PURGE_THRESHOLD + 1) * 3;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.