madv-free · shipping · also Linux MADV_FREE

MADV_FREE

MADV_FREE is a Linux memory-advice operation that makes private anonymous pages eligible for discard while allowing their contents to remain until reclamation.

Related Observatory article: MADV_FREE on hesela.com

Deferred discard: old contents can remain readable after success, but the application cannot rely on their retention. After reclamation, access obtains zero-filled memory; a write after advice but before reclamation cancels the pending discard for that page. This does not evict a file-backed cache range. [1]

Reclamation path: Linux v6.14 distinguishes lazy-free anonymous folios from ordinary swap-backed reclaim. Eligible contents can be discarded instead of preserved in swap. This is a source-level explanation, not a measurement of reclaim latency, memory savings or device I/O. [2]

Choice of operation: MADV_DONTNEED discards private anonymous contents without waiting for this deferred-reclaim opportunity. Neither operation is a secure-erasure procedure. Use MADV_FREE only after relinquishing the old data; it is not a durability operation for a mapped file. [1] [3]

Failure scope: an unmapped gap can produce ENOMEM even when mapped parts were processed. An error is not an unchanged-data guarantee. The v6.14 walker retains earlier effects if a later mapping fails. [4]

Relations

related
MADV_DONTNEED, MADV_REMOVE, Memory-mapped file, Page cache

Advantages

  • Allows disposable anonymous allocations to become reclaimable while retaining their virtual address range. [1]

Limitations

  • Only private anonymous mappings are eligible; success does not establish immediate reclamation. [1]

Citations

  1. Linux man-pages: madvise(2), memory-advice contracts (accessed 2026-11-09)
  2. Linux v6.14: lazy-free folio reclamation (accessed 2026-11-09)
  3. Hesela: lazy discard is not backing-file removal (accessed 2026-11-09)
  4. Linux v6.14: madvise range walking and partial effects (accessed 2026-11-09)

JSON: /data/terms/madv-free.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. MADV_FREE. Hesela. 2026-11-09. https://hesela.dev/terms/madv-free/