mmap

All posts tagged mmap by Linux Bash
  • Posted on
    Featured Image
    In Bash scripting, memory allocation plays a crucial role in script performance and reliability. Normally, Bash uses `mmap()` for large memory blocks, but it can be configured to use `malloc()`, which helps reduce virtual memory fragmentation and may enhance performance on some systems. Setting the `MALLOC_MMAP_THRESHOLD_` environment variable to 0 directs `malloc()` to never utilize `mmap()` for memory allocation. This adjustment is demonstrated through a sample script that showcases memory allocation in varied operations.
  • Posted on
    Featured Image
    The article discusses how to use `dd skip=` for `mmap`-like file reading in Linux. It explains `mmap` as a technique mapping files into memory for efficient access, contrasting it with `dd`, which doesn't use `mmap` but can mimic aspects by skipping to specific file parts, useful in large data sets. An example command provided is `dd if=largefile.bin of=segment.bin bs=1M skip=10 count=5`, demonstrating how to access file segments directly.