Buffer

ByteBuffer

构造

image.png
几个参数的作用:https://www.cnblogs.com/mjorcen/p/3992371.html
觉得是非常脑残的设计

image.png

image.png
image.png
GC本身并不负责堆外内存的清理,这里为什么要进行堆内存的GC回收呢?堆内存清理的再多又有什么用呢?
image.png
image.png
https://ezlippi.com/blog/2017/10/why-not-expliclitgc.html

写入

Heap写入
image.png

direct写入
image.png
image.png
image.png
这里注意下每次拷贝是有大小限制的

读取

Heap
写入的逆向方向,单个直接数组定位,批量直接System.arraycopy

Direct
写入的逆向操作,单个数组直接unsafe定位,批量根据大小来操作,同样存在每次拷贝有大小限制的情况

Channel

FileChannel

image.png
源码获取有点问题暂时不看

ServerSocketChannel