- For large jar files, free the per-entry
buffer
so it can be GC'ed.
- Get rid of some unnecessary array copies. IMO it might be nice to wrap the entire
OutputStream
passed to EntryAccounting
in a CountingOutputStream
and just stop returning bytes written everywhere.
- Increase the buffer size per entry to 8k and per file to 512k. The former shouldn't hurt since only one entry is live at a time per file (due to the first change). In total you would expect just around 520k of ram usage per file. Previously this would be somewhat unbounded, but for a zip file with 50k entries (this is Buck's jar) it would keep 8kb file buffer + 50000 * 1kb entry buffers - so around 50 megs. The actual build time for Buck's main jar is about the same, but if you build several large uberjars in parallel, there's fewer OOMs.