sebsite is a personal site that publishes short technical notes and experiments, and this page is one such note about reusing physical memory on Linux. Rather than a general tutorial, it records a single discovery the author found worth sharing, written in a casual first-person voice.
The core content is a minimal C example: create a memory-backed file descriptor with memfd_create, size it with ftruncate, map it shared, fill it with a template pattern, then map the same descriptor again with MAP_PRIVATE to obtain a copy. The author explains that the copy consumes no physical memory until pages are mutated, and that a single write only allocates one 4 KiB page while the rest stay shared.
A 32 MiB test is described to show the behavior in practice. The author also notes a wish for easier access to this pattern through higher-level standard library functions, which frames the trick as a low-level technique rather than a packaged API.
The page suits C and systems programmers already comfortable with mmap, file descriptors, and copy-on-write semantics, and it works best as a reference snippet to adapt rather than a step-by-step guide. Error handling is omitted, so readers should add their own checks before using it in production code.
Comments & Ratings
0No comments yet. Be the first to review.