Commit fe67148
Add maximum buffer size cap to ByteArrayOutputStream
Cap individual buffer allocations to 16MB to prevent excessive memory usage.
The previous implementation allowed buffers to double indefinitely, which could
lead to very large single allocations (32MB, 64MB, 128MB, etc.) that contribute
to heap exhaustion.
With this cap, when more than 16MB of data needs to be stored, the
ByteArrayOutputStream will create multiple 16MB buffers instead of one giant
buffer. This spreads the memory allocation across multiple smaller chunks
and prevents heap fragmentation issues.
Combined with the reduced threshold in ConcurrentJarCreator, this provides
defense-in-depth against OutOfMemoryError during zip archive creation.
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>1 parent 22c7383 commit fe67148
1 file changed
Lines changed: 9 additions & 0 deletions
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| |||
0 commit comments