Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Memory Management

  • pmap <pid>
    • any line showing ‘anon’ memory is the heap
  • page tables are supported directly by the CPU and memory management unit (MMU)
  • The page table turns logical memory addresses into real RAM addresses
  • The kernel allocates pages
  • Pages are allocated and mapped when a program is loaded at run time
  • When a program needs more memory, allocate from the heap
  • Processes that need a shared library will all reference the same pages for that shared object in memory
  • If you don’t have enough memory available, pages are swapped out to disk
    • Create swap space with mkswap
    • Start with swapon
    • Any partition with type 82 will be allocated as swap type at boot
  • /proc/<pid>/smaps
    • Detailed information about paging for a process
  • ‘/proc/meminfo’
  • RSS: Resident set size
    • How much virtual memory is in real memory
  • Thrashing