Computer Memory

How memory actually works, layer by layer.

How is the memory managed in the running program? How does the OS manage it when multiple programs are running? What are the memory related features that the CPU provides?

This course will guide you through understanding memory management, layer by layer, so that you can answer the questions above and write efficient programs.

Interactive
quizzes

26

Concepts and
exercises

175+
  1. 1

    Introduction to Memory

    What memory is, and how to represent it.

    1. Retrieving Data from a Computer

      Computers work by storing data both quickly and slowly, both persistently and temporarily.

    2. Binary, Decimal, and Hexadecimal

      These three numeric bases from discrete math are key for understanding how computers really work.

    3. Linear Memory Model

      Discover how every computer program really sees the computer's memory when you get under the hood.

    4. Memory Layout

      The linear memory model allows large pieces of data to be stored in byte-sized fragments.

  2. 2

    Memory of Programs

    Segments of memory.

    1. Included with
      Brilliant Premium

      Compiling Source Files to Executables

      The programs you run are made up of bytes in memory, just like everything else.

    2. Included with
      Brilliant Premium

      Memory Segments

      A running program uses four different parts of the computer's memory four different purposes.

    3. Included with
      Brilliant Premium

      The Code and Static Segments

      Some parts of memory are hold information that the program shouldn't be allowed to change.

    4. Included with
      Brilliant Premium

      The Stack Segment

      The stack allows multiple functions to work together.

  3. 3

    Virtual Memory

    How the OS manages memory.

    1. Included with
      Brilliant Premium

      Processes

      A computer can hold many programs, each of which think they're using the same memory. How can this be?

    2. Included with
      Brilliant Premium

      Virtual and Physical Memory

      Memory, as seen by every running computer program on your computer, is an elaborate virtual reality.

    3. Included with
      Brilliant Premium

      Memory Pages

      The computer's actual memory is managed in large chunks, called "pages."

    4. Included with
      Brilliant Premium

      MMU and the OS

      Your computer's processor and operating system work together to give each programs its own memory.

  4. 4

    Techniques for Performance

    OS features for efficient memory management.

    1. Included with
      Brilliant Premium

      Page Cache

      The page cache keeps information from the hard drive in RAM for faster access.

    2. Included with
      Brilliant Premium

      Memory Mapping

      A technique that helps the operating system access only small parts of big files.

    3. Included with
      Brilliant Premium

      Demand Load

      Even after you think you've opened a file, the operating system may be lying to you.

    4. Included with
      Brilliant Premium

      Page Sharing and Copy-on-Write

      Change is hard, and operating systems speed your computer up by assuming you'll avoid changes.

  5. 5

    Shared Libraries

    Linking and loading shared libraries to effectively reuse code.

    1. Included with
      Brilliant Premium

      Libraries

      Programs do not exist in isolation. When they run, they need to be connected to libraries.

    2. Included with
      Brilliant Premium

      Relocation

      After the compiler is done with your program, there is still missing information.

    3. Included with
      Brilliant Premium

      Position Independent Code

      An advanced technique can avoid the need for relocations.

    4. Included with
      Brilliant Premium

      Procedure Linkage Table

      See how the linkage information can be stored indirectly, without slowing programs down.

  6. 6

    Caching

    A fundamental technique to improve performance.

    1. Included with
      Brilliant Premium

      Caching Overview

      Caching is a fundamental technique for speeding up computer systems.

    2. Included with
      Brilliant Premium

      Details of Caching

      Computer processors use a few different techniques for deciding what to cache.

    3. Included with
      Brilliant Premium

      Practical Uses of Caching

      The same caching techniques apply to your computer and to the global internet.

    4. Included with
      Brilliant Premium

      DRAM, SRAM, and CPU Caches

      Caching always needs to consider tradeoffs between cost and performance.