ByteArrayPool 这个类是干嘛的
ByteArrayPool is a source and repository of <code>byte[]</code> objects. Its purpose is to supply those buffers to consumers who need to use them for a short period of time and then dispose of them. Simply creating and disposing such buffers in the conventional manner can considerable heap churn and garbage collection delays on Android, which lacks good management of short-lived heap objects. It may be advantageous to trade off some memory in the form of a permanently allocated pool of buffers in order to gain heap performance improvements; that is what this class does.
* <p>* A good candidate user for this class is something like an I/O system that uses large temporary <code>byte[]</code> buffers to copy data around. In these use cases, often the consumer wants the buffer to be a certain minimum size to ensure good performance (e.g. when copying data chunks off of a stream), but doesn't mind if the buffer is larger than the minimum. Taking this into account and also to maximize the odds of being able to reuse a recycled buffer, this class is free to return buffers larger than the requested size. The caller needs to be able to gracefully deal with getting buffers any size over the minimum. <p> If there is not a suitably-sized buffer in its recycling pool when a buffer is requested, this class will allocate a new buffer and return it. <p> This class has no special ownership of buffers it creates; the caller is free to take a buffer it receives from this pool, use it permanently, and never return it to the pool; additionally, it is not harmful to return to this pool a buffer that was allocated elsewhere, provided there are no other lingering references to it. <p> This class ensures that the total size of the buffers in its recycling pool never exceeds a certain byte limit. When a buffer is returned that would cause the pool to exceed the limit, least-recently-used buffers are disposed.
ByteArrayPool是<code> byte [] </ code>对象的源和存储库。其目的是将那些缓冲器供应给需要在短时间内使用它们的消费者,然后处理它们。简单地以常规方式创建和布置这样的缓冲器可以在Android上显着的堆乱动和垃圾收集延迟,其缺乏对短期堆对象的良好管理。可能有利的是以永久分配的缓冲器池的形式来折衷某些存储器,以便获得堆性能改进;这是这个类做的。
* <p>
*这个类的一个好的候选用户就像一个I / O系统,它使用大的临时<code> byte [] </ code>缓冲区来复制数据。在这些使用情况下,消费者通常希望缓冲器具有一定的最小大小以确保良好的性能(例如,当从流中复制数据块时),但是不介意缓冲器是否大于最小值。考虑到这一点,并且为了最大化能够重用再循环缓冲器的可能性,该类可以自由地返回大于所请求大小的缓冲区。调用者需要能够优雅地处理获得任何大小超过最小值的缓冲区。 <p>如果在请求缓冲区时在其回收池中没有适当大小的缓冲区,则此类将分配一个新缓冲区并返回。 <p>这个类没有对它创建的缓冲区的特殊所有权;调用者可以自由地获取从这个池接收的缓冲区,永久使用它,并且永远不会将其返回到池;此外,返回到这个池是没有害的,在其他地方分配的缓冲区,只要没有其他逗留的引用。 <p>此类确保其回收池中的缓冲区的总大小不会超过某个字节限制。当返回将导致池超过限制的缓冲区时,丢弃最近使用的缓冲区。
google翻译基本翻译出了主要意思
我润色一下。ByteArrayPool这个类是byte[]对象的一个仓库。它的目的是提供缓存区为那些需要短暂使用缓冲区的消费者并且做出处理。android系统自带的缓冲处理不能很好的满足短周期的堆对象。所以需要这个类来提供高性能的短生命期的堆管理。
第二段基本吻合。就不做处理了