kamranzafar / jtar

JTar is a simple Java Tar library, that provides an easy way to create and read tar files using IO streams. The API is very simple to use and similar to the java.util.zip package.
https://kamranzafar.org
Apache License 2.0
145 stars 45 forks source link

Replace FileOutputStream by nio Files.newOutputStream and Channels.newOutputStream #24

Open ghost opened 7 years ago

ghost commented 7 years ago

This patch reduces GC pressure.

FileOutputStream contains a finalizer which can cause excessive garbage collector pressure when writing many TAR files.

Finalizers are only executed when the GC feels like it. Until they are executed, objects with finalizers are not garbage collected. Internal benchmarks have shown that hundreds of thousands of FileOutputStream objects could remain in memory for a very long time as a result.

We've been using this internally for a few months, without any issues.