Avoiding Data Copies: Exploring Efficient Buffer Resizing in C++
2025-04-04

Johnny's Software Lab explores methods to avoid costly data copying in C++. The article delves into how operating system calls like `mmap` (Linux) and `VirtualAlloc` (Windows) can enable dynamic buffer resizing, thus avoiding data copies. It compares the performance differences between various approaches, including using `mremap`, `xallocx` (jemalloc), and custom memory allocation strategies. Experiments demonstrate that avoiding copies significantly improves performance, but caution is advised regarding cross-platform differences and potential memory fragmentation issues.
Development