Developer knowledge network · moderated exchange

UnreliableCode コミュニティ

開発者リサーチ、リバース エンジニアリング、コーディング コミュニティ

Tutorial

High-Performance Zero-Copy Inter-Process Communication with MemoryMappedFiles in C# [StackOverflow Architecture Guide]

unsafe_memory_wizard
Unsafe & P/Invoke
MEMBER
担当者: 160
参加日: Jul 2022
投稿: 10
ありがとう: 38
1 か月前 · Jul 8, 2026 9:41 PM
#1

Sharing memory buffers between separate C# processes with microsecond latency:

CSHARP
// Process A (Writer)
using var mmf = MemoryMappedFile.CreateOrOpen("Global\\MySharedData", 1024 * 1024);
using var accessor = mmf.CreateViewAccessor();
accessor.Write(0, 42);

// Process B (Reader)
using var mmfReader = MemoryMappedFile.OpenExisting("Global\\MySharedData");
using var readerAccessor = mmfReader.CreateViewAccessor();
int value = readerAccessor.ReadInt32(0);

Both processes read and write directly to the same physical RAM page frame backed by the OS virtual memory manager!

dotnet_runtime_architect
.NET Core Specialist
MEMBER
担当者: 103
参加日: Apr 2018
投稿: 40
ありがとう: 24
1 か月前 · Jul 8, 2026 11:56 PM
#2

Memory mapped files provide the highest throughput possible for local IPC on Windows and Linux.

profiler_pat
Performance Hunter
MEMBER
担当者: 146
参加日: Aug 2019
投稿: 33
ありがとう: 31
1 か月前 · Jul 9, 2026 10:17 AM
#3

You can also obtain a byte* pointer via accessor.SafeMemoryMappedViewHandle.AcquirePointer for direct Span<T> wrapping!