Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No, the virtual address space of a process is not necessarily contiguous. In the old days, a process obtained memory through <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/brk.2.html" rel="nofollow noreferrer"><code>brk</code></a>, which indeed forced the process heap to be a contiguous zone of memory. Nowadays memory allocation is done through <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/mmap.2.html" rel="nofollow noreferrer"><code>mmap</code></a>, which can manipulate the process's virtual memory page by page.</p> <p>If you're curious about the kernel side of things, I recommend two references:</p> <ul> <li>Read a book on the Linux kernel, such as <a href="http://lwn.net/Kernel/LDD3/" rel="nofollow noreferrer"><em>Linux Device Drivers</em> by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman</a>, in particular <a href="http://lwn.net/images/pdf/LDD3/ch08.pdf" rel="nofollow noreferrer">chapter 8 (Allocating Memory)</a>.</li> <li>Browse the kernel code through <a href="http://lxr.linux.no/linux" rel="nofollow noreferrer">LXR, the Linux kernel cross-reference</a>. The memory management code is in the <a href="http://lxr.linux.no/#linux+v2.6.38/mm" rel="nofollow noreferrer"><code>mm</code> directory</a>; start with <a href="http://lxr.linux.no/#linux+v2.6.38/mm/mmap.c" rel="nofollow noreferrer"><code>mmap.c</code></a> or <a href="http://lxr.linux.no/#linux+v2.6.38/include/linux/mm.h" rel="nofollow noreferrer"><code>mm.h</code></a>.</li> </ul> <p>If you'd like to explore around on your system, you can see each process's memory mapping in <code>/proc/$pid/maps</code>. See <a href="https://unix.stackexchange.com/questions/6301/how-do-i-read-from-proc-pid-mem-under-linux">How do I read from /proc/$pid/mem under Linux?</a> for more information.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload