Start 提交收录

sebsite

sebsite.pwDR 29 正常访问 300 浏览

开发编程 A personal blog post explaining a Linux memory trick that uses memfd_create and mmap with MAP_PRIVATE to duplicate large memory templates via copy-on-write without upfront physical allocation.

主编点评

仅供参考
sebsite 页面预览

The post is a focused, code-first write-up aimed at systems programmers, walking through a concrete memfd_create plus mmap workflow and a 32 MiB test. Its value lies in the precise page-level explanation of copy-on-write behavior; readers wanting broader context or higher-level language examples wil

站点介绍

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.

评论与评分

0

还没有评论,来写下第一条评价吧。

写下第一条评论

邮箱不会被公开,带 * 的为必填项。

为这个站点评分

点击星星打分,评分可选,再次点击已选星星可取消。