From d8b225d2c3d55d41b5c0f7b9a342a15d7eee42c8 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 14 Jun 2019 12:17:36 -0700 Subject: [PATCH] Fixed #539 (max recyclable chunk length reduction) --- release-notes/VERSION-2.x | 1 + .../com/fasterxml/jackson/core/util/ByteArrayBuilder.java | 8 ++++---- .../java/com/fasterxml/jackson/core/util/TextBuffer.java | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index a27d2d77d8..42df02c740 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -31,6 +31,7 @@ JSON library. #508: Add new exception type `InputCoercionException` to be used for failed coercions like overflow for `int` #527: Add simple module-info for JDK9+, using Moditect +#539: Reduce max size of recycled byte[]/char[] blocks by `TextBuffer`, `ByteArrayBuilder` 2.9.9 (16-May-2019) diff --git a/src/main/java/com/fasterxml/jackson/core/util/ByteArrayBuilder.java b/src/main/java/com/fasterxml/jackson/core/util/ByteArrayBuilder.java index eef2047f3b..4e9e031622 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/ByteArrayBuilder.java +++ b/src/main/java/com/fasterxml/jackson/core/util/ByteArrayBuilder.java @@ -33,10 +33,10 @@ public final class ByteArrayBuilder extends OutputStream // Size of the first block we will allocate. private final static int INITIAL_BLOCK_SIZE = 500; - // Maximum block size we will use for individual non-aggregated - // blocks. Let's limit to using 256k chunks. - private final static int MAX_BLOCK_SIZE = (1 << 18); - + // Maximum block size we will use for individual non-aggregated blocks. + // For 2.10, let's limit to using 128k chunks (was 256k up to 2.9) + private final static int MAX_BLOCK_SIZE = (1 << 17); + final static int DEFAULT_BLOCK_ARRAY_SIZE = 40; // Optional buffer recycler instance that we can use for allocating the first block. diff --git a/src/main/java/com/fasterxml/jackson/core/util/TextBuffer.java b/src/main/java/com/fasterxml/jackson/core/util/TextBuffer.java index 0dee2bf76d..90a29cd89c 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/TextBuffer.java +++ b/src/main/java/com/fasterxml/jackson/core/util/TextBuffer.java @@ -34,10 +34,10 @@ public final class TextBuffer final static int MIN_SEGMENT_LEN = 1000; /** - * Let's limit maximum segment length to something sensible - * like 256k + * Let's limit maximum segment length to something sensible. + * For 2.10, let's limit to using 64kc chunks (128 kB) -- was 256kC/512kB up to 2.9 */ - final static int MAX_SEGMENT_LEN = 0x40000; + final static int MAX_SEGMENT_LEN = 0x10000; /* /**********************************************************