[jira] [Resolved] (COMPRESS-172) Reuse of buffers while reading stream and skipping stream

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] [Resolved] (COMPRESS-172) Reuse of buffers while reading stream and skipping stream

Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/COMPRESS-172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved COMPRESS-172.

       Resolution: Fixed
    Fix Version/s: 1.5

I did a bit more than you suggested in svn revision 1429363

AFAICS your patch to TarBuffer wouldn't be safe since readRecord (which is public and could be used by anyone) returns a reference to the result-array.

> Reuse of buffers while reading stream and skipping stream
> ---------------------------------------------------------
>                 Key: COMPRESS-172
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-172
>             Project: Commons Compress
>          Issue Type: Improvement
>          Components: Archivers
>    Affects Versions: 1.3
>            Reporter: Thomas Mair
>            Priority: Minor
>              Labels: patch
>             Fix For: 1.5
>         Attachments: tarbuffer.patch
>   Original Estimate: 10m
>  Remaining Estimate: 10m
> When reading a tar archive from a stream for each record a new buffer is allocated. This will cause many new objects that later get collected by the garbage collector. The same issue exists when we are skipping entries. Instead of allocating new buffers we could reuse one single buffer. This saves some GC overhead as well as the time needed to allocate new memory. I created a small patch fixing this issue. I did not test this patch thoughtfully, but it should not cause any trouble, as the buffers never leave their respective classes.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira