RFR 8203768 : Avoid reallocation in java.base/unix/classes/java/lang/ProcessImpl.java

Martin Buchholz martinrb at google.com
Tue Jun 5 16:40:14 UTC 2018


On Mon, Jun 4, 2018 at 10:31 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com>
wrote:

> But suppose available() incorrectly claims that a million bytes are
> available, but you only read 10.  Then there's a tradeoff - the cost of
> reallocation versus the risk that the mostly empty backing array will be
> retained for a long time if the Process object is not garbage collected.
>
> On the other hand, if available() claims a million bytes, and then only
> 999999990 bytes were read, there will be mostly unnecessary allocation and
> copying.
>
>
Yup.


> I'm leaning towards the status quo.
>
> Okay, let's leave it as is :)
> It was meant mostly for cleaning up the code, so if there is a doubt, then
> it's better keep what we have.
>

If your version were the status quo, it would not be worth changing.  When
in doubt, status quo wins.


More information about the core-libs-dev mailing list