1.2 Memory and Storage

OCR GCSE Computer Science J277

1.2.1 Primary storage (memory)

Primary storage is memory that the CPU can access directly. It includes RAM and ROM.


RAM

  • Random Access Memory

  • Volatile - loses its contents when the power is switched off.

  • Can be read from and written to.

  • Holds the operating system, programs, and data that are currently in use.

  • More RAM lets you run more programs at once (or larger programs) without slowing down.


ROM

  • Read Only Memory

  • Non-volatile - keeps its contents after power is lost.

  • Read only - cannot normally be changed.

  • Holds the boot program (bootstrap / BIOS) that starts the computer and loads the operating system into RAM.


RAM vs ROM


RAM

ROM

Volatile?

Yes

No

Read/write?

Read and write

Read only

Holds

OS, programs, data in use

Boot/start-up instructions

Usually measured in

GBs

MBs


Virtual Memory

Virtual memory is a section of secondary storage used as if it were RAM.

When RAM becomes full, the operating system moves data that isn't currently needed out to virtual memory, freeing up RAM for active data.

When the CPU wants to work on something that has been moved to virtual memory, we first need to make space in RAM and then move the data back from virtual memory to RAM. This is a slow process since we are limited by the access speeds of secondary storage. Therefore, heavy use of virtual memory (because we are frequently running out of space in RAM) slows down computer performance.

Exam trap - "Memory" means primary storage (RAM/ROM), not the hard drive/SSD. Don't call an SSD's capacity "memory."


1.2.2 Secondary storage

Secondary storage is non-volatile storage used to keep programs, files, and the OS long-term.

Computer systems need secondary storage so that programs, files and the OS are kept when the device is turned off.

There are 3 types of storage medium we use for secondary storage:

  • magnetic

  • optical

  • solid state


Characteristics of secondary storage

To help us compare secondary storage options we look at the following characteristics:

  • Capacity: The amount of data that can be stored, usually measured in gigabytes (GB) or terabytes (TB).

  • Access Speed: The rate at which data can be read from or written to the storage device, affecting overall system performance.

  • Durability: The ability of the storage medium to withstand use and damage.

  • Cost per GB: The price per unit of storage.

  • Portability: The ease with which the storage device can be transported or accessed, usually looking at size and weight.

  • Reliability: The consistency of the storage medium to perform correctly, ensuring that data remains accessible and intact over time.


Magnetic

Data is stored as magnetised patterns on spinning platters, accessed by a moving read/write head.

Image from Ada CS
  • Capacity: πŸ‘ High capacity

  • Access Speed: πŸ‘Ž Slow access speeds - have to physically spin the platter and move the read/write head to the particular part of the platter.

  • Durability: πŸ‘Ž Not durable - when bumped, the platters and read/write head can move and get damaged.

  • Cost per GB: πŸ‘ Low cost per GB

  • Portability: Not very portable - bigger and heavier than optical and solid state, and need to be careful due to poor durability.

  • Reliability: πŸ‘ Decently reliable


Optical

Optical (e.g. CD, DVD, Blu-ray) - data is stored as pits and lands on a reflective disc, read by a laser.

Image from Ada CS
  • Capacity:

  • Access Speed:

  • Durability:

  • Cost per GB:

  • Portability:

  • Reliability:

Solid State

Solid state (e.g. SSD, USB stick, memory card) - data is stored electronically in flash memory, with no moving parts.

  • Fast, durable, silent, low power - but more expensive per GB and has a limited number of read/write cycles.

When choosing storage for a scenario, weigh these characteristics: capacity, speed, portability, durability, reliability, cost.

  • Capacity:

  • Access Speed:

  • Durability:

  • Cost per GB:

  • Portability:

  • Reliability:

Exam trap - SSDs have no moving parts (a common misconception). When justifying a choice of device, always link your reason to a characteristic (e.g. "an SSD because it's more durable for a device that gets carried around").


1.2.3 Units

Unit

Size

Bit (b)

a single binary digit (0 or 1)

Nibble

4 bits

Byte (B)

8 bits

Kilobyte (KB)

1,000 bytes

Megabyte (MB)

1,000 KB

Gigabyte (GB)

1,000 MB

Terabyte (TB)

1,000 GB

Petabyte (PB)

1,000 TB

Computers are built from transistors that have two states (on/off), represented as 1 and 0. So all data - numbers, text, images, sound - must be converted into binary to be stored and processed.

Worked example (capacity) - How many 2 MB photos fit on a 1 GB drive? 1 GB = 1,000 MB, so 1,000 Γ· 2 = 500 photos.

Exam trap - OCR uses 1 KB = 1,000 bytes (not 1,024). Using 1,024 will cost marks in calculations. Also: b = bit, B = byte.

Estimating File Sizes



1.2.4 Data storage

Numbers

Denary β†’ binary (0-255) using 8-bit place values:

128 64 32 16 8 4 2 1

Worked example - 210 = 128 + 64 + 16 + 2 β†’ 1101 0010.

Binary β†’ denary - add the place values wherever there's a 1.

Binary addition rules: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).

Worked example (in range) -

  0010 1010   (42)
+ 0001 0101   (21)
= 0011 1111   (63)

Worked example (overflow) -

  1000 0000   (128)
+ 1000 0001   (129)

The two leftmost bits give 1+1, producing a carry out of the 8-bit byte. 128 + 129 = 257, which needs more than 8 bits, so it can't be stored correctly - this is an overflow error.

Denary β†’ hexadecimal (0-255) - two hex digits (0-9 then A-F for 10-15).

Worked example - 210 Γ· 16 = 13 remainder 2 β†’ 13 = D, 2 = 2 β†’ D2.

Binary ↔ hex - split the binary into nibbles and convert each.

Worked example - 1101 0010 β†’ 1101 = D, 0010 = 2 β†’ D2 (which is 210, matching above).

Hexadecimal is used because it's shorter and easier for humans to read and write than long binary, and each hex digit maps neatly to one nibble.

Exam trap - Hex is for humans, not because "the computer understands hex." The computer still works entirely in binary.

Binary shifts

  • Left shift by n places multiplies by 2ⁿ; zeros fill in on the right.

  • Right shift by n places divides by 2ⁿ (whole-number division); zeros fill in on the left.

  • Bits shifted off the end are lost.

Worked example - 0000 0110 (6) left shift 1 β†’ 0000 1100 (12) = 6 Γ— 2. Right shift 1 β†’ 0000 0011 (3) = 6 Γ· 2. But 0000 0011 (3) right shift 1 β†’ 0000 0001 (1): the shifted-off bit is lost, so 3 Γ· 2 rounds down to 1.

Characters

A character set is the collection of characters a computer can represent, each with a unique binary code.

  • ASCII - 7 bits, 128 characters (extended ASCII uses 8 bits for 256).

  • Unicode - uses more bits per character, so it can represent far more characters, covering most world languages and emoji.

Number of characters = 2^(bits per character).

Worked example - 7 bits β†’ 2⁷ = 128 characters (ASCII).

Exam trap - Character codes are ordered and consecutive: 'A' = 65, 'a' = 97. So if you know 'A' = 65, then 'C' = 67. To store text: bits per character Γ— number of characters.

Images

A bitmap image is a grid of pixels, and each pixel's colour is stored as a binary code.

  • Colour depth = number of bits per pixel. Number of colours = 2^(colour depth) (1 bit β†’ 2 colours; 8 bits β†’ 256).

  • Resolution = the number of pixels (e.g. width Γ— height).

  • Metadata = data stored about the image (width, height, colour depth, file type, date) so it can be interpreted and displayed correctly.

Higher resolution and/or greater colour depth β†’ better quality but larger file size.

File size (bits) = width Γ— height Γ— colour depth. Divide by 8 for bytes.

Worked example - A 100 Γ— 100 pixel image at colour depth 8 = 100 Γ— 100 Γ— 8 = 80,000 bits = 10,000 bytes = 10 KB.

Exam trap - Resolution (number of pixels) and colour depth (bits per pixel) are different things - more pixels doesn't mean more colours.

Sound

Sound is analogue and must be sampled to be stored digitally. Sampling measures the amplitude of the sound wave at regular intervals.

  • Sample rate = samples taken per second, measured in hertz (Hz).

  • Bit depth = number of bits used per sample.

  • Duration = length in seconds.

Higher sample rate, higher bit depth, or longer duration β†’ larger file size (higher rate/depth also β†’ better quality).

File size (bits) = sample rate Γ— bit depth Γ— duration. Divide by 8 for bytes.

Worked example - 44,100 Hz Γ— 16 bits Γ— 10 s = 7,056,000 bits = 882,000 bytes = 882 KB.

Exam trap - A higher sample rate or bit depth makes the file bigger, not smaller. Students often assume "better quality = smaller."


1.2.5 Compression

Compression reduces file size so files take up less storage, transfer faster, and use less bandwidth.

Lossless - reduces size with no loss of data; the original can be perfectly reconstructed (e.g. by removing redundancy). Used where every bit matters (text, PNG). Files stay larger than lossy.

Lossy - permanently removes some data (often detail people are less likely to notice) for much smaller files, but quality is reduced and the original cannot be recovered (e.g. MP3, JPEG).

Exam trap - Lossless is not "no compression," and lossy is not reversible - you can never get the original file back from a lossy version.