You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Vladimír Váša (Jira)" <ji...@apache.org> on 2021/10/04 09:22:00 UTC
[jira] [Created] (IO-752) Use LinkedList in
org.apache.commons.io.output.AbstractByteArrayOutputStream
Vladimír Váša created IO-752:
--------------------------------
Summary: Use LinkedList in org.apache.commons.io.output.AbstractByteArrayOutputStream
Key: IO-752
URL: https://issues.apache.org/jira/browse/IO-752
Project: Commons IO
Issue Type: Improvement
Components: Streams/Writers
Affects Versions: 2.11.0
Reporter: Vladimír Váša
Hi,
org.apache.commons.io.output.AbstractByteArrayOutputStream is super class which
(unlike java.io.ByteArrayOutputStream)
not realocate memory/copy arrays - if data buffer is groving.
Instead of it use List of 1KB byte[] chunks and simply add new chunk into list.
{color:#cc7832}private final {color}List{color:#9876aa}<{color}{color:#cc7832}byte{color}{color:#9876aa}[]> {color}{color:#9876aa}buffers {color}= {color:#cc7832}new {color}ArrayList{color:#9876aa}<>(){color}{color:#cc7832};{color}
But as List implementation there is used "ArrayList" so the "array of pointers to chunks" is stil realocated in memory.
I suggest to use LinkedList instead.
With best regards
Vladimir Vasa
--
This message was sent by Atlassian Jira
(v8.3.4#803005)