Skip to content

Commit 22c7383

Browse files
Copilotslachiewicz
andcommitted
Reduce heap usage threshold from 100MB to 10MB in ConcurrentJarCreator
The previous threshold of 100000000 (100MB) divided by number of threads was causing OutOfMemoryError issues when creating zip archives, particularly in environments with limited heap space like CI systems. The ByteArrayOutputStream used internally can grow up to 2x the threshold before switching to disk-based storage, leading to excessive memory consumption. Reducing to 10000000 (10MB) reduces memory pressure while still maintaining reasonable performance. For typical builds with 4 threads, this means: - Before: 25MB per stream (potentially 50MB+ with buffer doubling) - After: 2.5MB per stream (potentially 5MB+ with buffer doubling) This change addresses the heap space errors reported in apache/maven CI builds. Co-authored-by: slachiewicz <[email protected]>
1 parent 173d14b commit 22c7383

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public ConcurrentJarCreator(int nThreads) throws IOException {
112112
*/
113113
public ConcurrentJarCreator(boolean compressAddedZips, int nThreads) throws IOException {
114114
this.compressAddedZips = compressAddedZips;
115-
ScatterGatherBackingStoreSupplier defaultSupplier = new DeferredSupplier(100000000 / nThreads);
115+
ScatterGatherBackingStoreSupplier defaultSupplier = new DeferredSupplier(10000000 / nThreads);
116116
metaInfDir = createDeferred(defaultSupplier);
117117
manifest = createDeferred(defaultSupplier);
118118
directories = createDeferred(defaultSupplier);

0 commit comments

Comments
 (0)