sun.nio.ch.Util: Don't cache an unlimited amount of memory
Evan Jones
ej at evanjones.ca
Wed Dec 30 14:41:18 UTC 2015
On Tue, Dec 29, 2015 at 12:47 PM, Uwe Schindler <uschindler at apache.org>
wrote:
>
> There is more stuff affected by this: Also the „good old” RandomAccessFile
> or FileInput/OutputStream. Although those don’t use DirectBuffers
> internally, those allocate a native buffer with libc’s malloc() if the
> byte[] is larger than 8192 bytes. If you transfer a large byte[] using
> those old APIs it allocates (only for short time, so its better) a malloced
> buffer. But this buffer is freed after transfer, but its also an overhead
> as it fragments libc’s heap. If you buffer is < 8192 bytes it uses a buffer
> on stack, so when using those old APIs prefer to chunk at 8192 bytes.
>
This is another argument that my naive proposal of not caching more buffers
than some limited size (e.g. 1 MB) may not be totally crazy: it wouldn't be
worse than traditional Java I/O, that executes malloc and free for each I/O.
--
Evan Jones
http://evanjones.ca/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20151230/9657b199/attachment-0001.html>
More information about the nio-dev
mailing list