您好,尝试了解零复制原理。维基百科说
Several operating systems support zero-copying of files through specific APIs.
The Linux kernel supports zero-copy through various system calls, such as sys/socket.h's sendfile, sendfile64, and splice. Some of them are specified in POSIX and thus also present in the BSD kernels or IBM AIX, some are unique to the Linux kernel API.
Microsoft Windows supports zero-copy through the TransmitFile API.
Java input streams can support zero-copy through the java.nio.channels.FileChannel's transferTo() method if the underlying operating system also supports zero copy.[4]
我没有看到任何提及 OSX 的内容,尽管它说存在于 BSD 内核中。
但是http://www.bigfastblog.com/zero-copy-transfer-data-faster-in-ruby博客说 OSX 不支持它。
最佳答案
有一个man page for sendfile对于 OS X。虽然它没有引用零复制,但它确实将 sendfile 作为系统调用(与打开/读/写/关闭周围的一些包装器相反),所以我认为可以很安全地假设它不会涉及将文件复制到用户空间。
关于java - Mac 是否支持零复制原理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30772456/