AlgoMaster Logo

Zero-Copy: sendfile, splice, and mmap

Medium Priority13 min readUpdated August 14, 2026

Suppose a static-file server needs to send a 1 GB file over a socket. The application does not inspect or modify the data, yet a traditional approach copies every byte through a temporary user-space buffer:

That buffer exists only to move unchanged data from the file to the socket. For large transfers, these extra copies consume CPU time, memory bandwidth, and cache space.

Zero-copy techniques reduce this overhead by avoiding one or more unnecessary copies through user space.

The name can be misleading: the data may still move between storage, memory, and network devices. The key idea is simply to remove unnecessary CPU-mediated copies from the data path.

This chapter traces the conventional transfer path, compares sendfile, splice, tee, vmsplice, mmap, and MSG_ZEROCOPY, and explains when copy avoidance improves end-to-end performance.

Premium Content

Subscribe to unlock full access to this content and more premium articles.