Skip to main content
Use “allocate” and “reserve” coherently, and explain the difference.
Source Link
Stephen Kitt
  • 480.9k
  • 59
  • 1.2k
  • 1.4k

If they allocate memory at all, they only allocatereserve it as space in swap.

mmap, malloc, and shmget reserveallocate space in the calling process’ address space; on Linux, mmap and shmget also allocatereserve space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified). They don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Memory isActual pages of memory are allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, and written to, non-locked memory can be swapped out, but that happens later if at all.

(By “reserve”, I mean that the corresponding amount of storage is set aside for the process; by “allocate”, I mean that specific resources are assigned to the process, e.g. addresses in the virtual address space, or pages in memory.)

If they allocate memory at all, they only allocate it as space in swap.

mmap, malloc, and shmget reserve space in the calling process’ address space; on Linux, mmap and shmget also allocate space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified). They don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Memory is allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, non-locked memory can be swapped out, but that happens later if at all.

If they allocate memory at all, they only reserve it as space in swap.

mmap, malloc, and shmget allocate space in the calling process’ address space; on Linux, mmap and shmget also reserve space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified). They don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Actual pages of memory are allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, and written to, non-locked memory can be swapped out, but that happens later if at all.

(By “reserve”, I mean that the corresponding amount of storage is set aside for the process; by “allocate”, I mean that specific resources are assigned to the process, e.g. addresses in the virtual address space, or pages in memory.)

malloc too.
Source Link
Stephen Kitt
  • 480.9k
  • 59
  • 1.2k
  • 1.4k

If they allocate memory at all, they only allocate it as space in swap.

mmap, malloc, and shmget reserve space in the calling process’ address spacespace; on Linux, mmap and shmget also allocate space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified); they. They don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Memory is allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, non-locked memory can be swapped out, but that happens later if at all.

If they allocate memory at all, they only allocate it as space in swap.

mmap and shmget reserve space in the calling process’ address space, and space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified); they don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Memory is allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, non-locked memory can be swapped out, but that happens later if at all.

If they allocate memory at all, they only allocate it as space in swap.

mmap, malloc, and shmget reserve space in the calling process’ address space; on Linux, mmap and shmget also allocate space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified). They don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Memory is allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, non-locked memory can be swapped out, but that happens later if at all.

Source Link
Stephen Kitt
  • 480.9k
  • 59
  • 1.2k
  • 1.4k

If they allocate memory at all, they only allocate it as space in swap.

mmap and shmget reserve space in the calling process’ address space, and space in swap space (unless MAP_NORESERVE or SHM_NORESERVE are specified); they don’t allocate backing physical memory. shm_open doesn’t allocate memory either: it’s used to open an existing object, or create a new 0-length object.

Memory is allocated when addresses in the address space are dereferenced. That allocation always happens in physical memory, if it’s possible at all; otherwise the process wouldn’t be able to read or write there. After it’s allocated, non-locked memory can be swapped out, but that happens later if at all.