1 of 18

WORKING WITH MEMORY IN OPERATING SYSTEMS.

2 of 18

INTRODUCTION

  • πŸ“Œ What is memory in an operating system?
  • Memory is one of the key resources of a computer used to store data and instructions during program execution.
  • Includes random access memory (RAM), cache memory, virtual memory, and persistent storage.
  • πŸ”§ The role of memory management:
  • Efficient memory allocation between processes.
  • Protecting the memory of different processes from each other.
  • Providing multitasking.
  • Support for virtual memory and paging.
  • πŸš€ Relevance of the topic:
  • Modern operating systems operate with limited resources and many parallel processes.
  • The stability, performance, and security of your system depend on the quality of memory management.
  • New architectures and tasks (e.g. virtualization, AI) require increasingly advanced memory management mechanisms.

3 of 18

BASIC CONCEPTS

  • 🧩 Random Access Memory (RAM)
  • Fast, volatile memory used to temporarily store data and instructions.
  • It is the main working space of processes in the OS.
  • The amount of RAM directly affects system performance.
  • 🌐 Virtual memory
  • A mechanism that allows a disk to be used as an extension of RAM.
  • Provides the illusion of a continuous and large amount of memory for each process.
  • Allows you to run more programs than the RAM is physically available for.
  • πŸ“ Address space
  • The set of addresses that a process can use.
  • Each process is given its own isolated address space.
  • In modern operating systems, this is implemented through mechanisms for mapping virtual addresses to physical ones.

4 of 18

MEMORY MANAGEMENT TASKS

βš™οΈ Efficiency

  • Maximum use of available RAM.
  • Reducing data access time.
  • Support for caching, buffering and optimal data placement.

πŸ”’ Security

  • Isolation of process address spaces.
  • Protection against unauthorized access to memory.
  • Preventing buffer overflows and memory leaks.

πŸ”„ Multitasking

  • Support for simultaneous execution of multiple processes.
  • Managing memory distribution between active tasks.
  • Support for priorities and preemption.

5 of 18

TYPES OF MEMORY IN OPERATING SYSTEMS

🧱 Physical and virtual memory

  • Physical memory (RAM) is the actual running memory of the device.

  • Virtual memory is a logical extension of physical memory using a disk (swap file ) .

⚑ Cache, buffers, swap

  • Cache is a fast memory for storing frequently used data, speeding up access.
  • Buffers are temporary storage of data during input/output (for example, a print buffer).
  • Swap is an area on the disk for unloading rarely used pages from RAM.

πŸ•’ Permanent and temporary memory

  • Non -volatile - retains data when power is turned off (e.g. SSD, HDD).
  • Volatile - loses its contents when power is turned off (e.g. RAM, cache).

6 of 18

COMPARISON TABLE: MEMORY TYPES IN OS

Memory type

Purpose

Peculiarities

Examples

🧱 Physical memory

The device's main RAM

Fast, limited volume, energy-dependent

RAM

🧱 Virtual memory

Expanding physical memory using a disk

Uses a swap file (Windows) or swap partition (Linux/macOS)

Pagefile.sys, swap

⚑ Cash

Storing frequently used data

Located closer to the processor (L1/L2/L3), high speed

CPU Cache, disk/file cache

⚑ Buffer

Temporary storage of data during input/output

Smooths out speed differences between devices

Print buffer, file buffer

⚑ Swap

Unloading rarely used data from RAM

Slows down performance if used actively, but avoids system crashes

Swap partition, pagefile

πŸ•’ Permanent memory

Long-term data storage

Does not lose data when power is turned off

SSD, HDD, ROM

πŸ•’ Temporary memory

Temporary storage of data during system operation

Fast, but clears when rebooting or powering off

RAM, cache

7 of 18

VIRTUAL MEMORY

πŸ“Œ What is this?

  • A mechanism that allows processes to operate with a larger logical memory capacity than is physically available.
  • The OS maps virtual addresses to physical ones using special tables (MMU - memory management unit).

πŸ“„ The principle of page organization

  • Memory is divided into pages (usually 4 KB).
  • Virtual memory is divided into virtual pages, which are mapped to physical frames .
  • Pages are loaded as needed ( lazy loading ).

βœ… Advantages:

  • Process isolation and security.
  • Efficient use of physical memory.
  • Ability to run programs that exceed the RAM capacity.

❌ Disadvantages:

  • Slowdown with active use of swap ( paging ).
  • Difficulty of implementation.
  • Possibility of fragmentation and freezing due to insufficient memory.

8 of 18

WORKING WITH MEMORY IN WINDOWS

  • 🧩 Memory Management Architecture
  • Windows uses paging virtual memory .
  • Each process gets its own virtual address space (up to 8 TB on 64-bit systems).
  • Management is carried out through the Memory Manager in the OS kernel.
  • 🧱 Key components:
  • Pagefile.sys is a paging file on the disk, used when there is not enough RAM.
  • Memory Manager :
    • Manages page distribution,
    • Implements eviction algorithms,
    • Controls access to memory.
  • πŸ›  Analysis tools:
  • Task Manager :
    • Quickly view memory usage by process.
  • Resource Monitor :
    • Detailed analysis: physical, reserved and swapped memory,
    • Real-time memory activity graphs and diagnostics.

9 of 18

WORKING WITH MEMORY IN LINUX

🧱 Key components:

  • Swap is an area on the disk for temporary storage of inactive memory pages.
  • Cgroups (Control Groups ) are a mechanism for limiting and controlling the use of resources (including memory) by groups of processes.
  • OOM killer (Out-Of-Memory Killer ) is a process that terminates tasks when there is insufficient memory to avoid a system crash.

πŸ›  Basic commands:

  • free - shows total, used and free space in memory and swap .
  • top , htop β€” real-time memory usage monitoring ( htop β€” with color interface).
  • vmstat β€” statistics on virtual memory, swap, input/output.
  • cat / proc / meminfo - Detailed information about the current memory state from the proc virtual filesystem .

10 of 18

WORKING WITH MEMORY IN MACOS

🧬Darwin

  • macOS is based on the XNU kernel ( a Mach +BSD hybrid) – part of the Darwin architecture .
  • Memory management is implemented through virtual memory with dynamic allocation .
  • Each process is isolated and uses its own address space.

🧱 Key components:

  • Swap - is actively used, even when there is free RAM.
  • Intelligent management: The system automatically moves data between RAM and swap to optimize performance.

πŸ›  Tools:

  • Activity Monitor (System Monitoring) :
    • Graphical tool for monitoring memory usage.
    • Shows the division of memory into App Memory, Wired , Compressed , etc.
  • vm_stat is a terminal tool for analyzing the state of virtual memory.
  • top - displays active processes and resource usage in real time.

11 of 18

COMPARISON TABLE: WORKING WITH MEMORY IN THE OS

operating system

Swap / Paging

Tools

Flexibility of customization

Windows

Pagefile.sys

Task Manager, Resource Monitor

Average

Linux

Swap

free, top, htop, vmstat

High

macOS

Swap

Activity Monitor, vm_stat, top

Limited

πŸ“ Note:

  • In Linux, you can fine-tune swap behavior, memory limits, and priorities using sysctl , cgroups , and swappiness .
  • In Windows, the setting is less flexible, but is available through system settings.
  • In macOS, memory settings are hidden from the userβ€”system behavior is adjusted automatically.

12 of 18

PROBLEMS AND CHALLENGES WHEN WORKING WITH MEMORY

πŸ’§ Memory Leaks

  • Occurs when a program fails to free up unused memory.
  • Gradually reduce available memory, which can lead to crashes.
  • This is especially critical for long-running processes and server applications.

πŸ” Thrashing (repeated pumping)

  • A condition in which the OS spends more time managing memory than running processes.
  • Often associated with lack of RAM and heavy swap usage .
  • Drastically reduces system performance.

🐒 Performance issues

  • Inefficient memory allocation between processes.
  • Poor virtual memory settings.
  • Excessive resource usage by individual applications.

13 of 18

OPTIMIZING MEMORY USAGE

βš™οΈ Swap settings

  • Adjusting the swappiness parameter in Linux to balance between RAM and swap .
  • Configuring pagefile.sys size in Windows.
  • On macOS , the capabilities are limited, but you can monitor usage and restart resource-intensive processes.

πŸ“Š Monitoring and cleaning

  • Using tools: htop , Task Manager, Activity Monitor, etc.
  • Terminate unused or memory-hungry processes.
  • Using automatic garbage collectors in applications (at the code level).

πŸ’Ύ Hardware solutions

  • Increasing the amount of RAM (RAM upgrade ) is the most effective way to improve performance.
  • Using faster storage devices (SSD) to speed up swap.
  • Multi-channel memory operation mode ( dual / triple channel ) to increase throughput.

14 of 18

PRACTICAL PART

πŸ”Ή Task 1 (Windows): Analyzing Memory in Task Manager

πŸ›  Task:

  1. Open Task Manager ( Ctrl + Shift + Esc ).
  2. Go to the "Processes" tab .
  3. Sort the list by the "Memory" column .
  4. Find the processes that are consuming the most memory .

❓ Discussion questions:

  • Which processes consume the most memory?
  • Are they system or user?
  • Are there any stuck/idle processes with high consumption?

πŸ”„ How does swap affect?

  • Is the paging file (pagefile.sys) starting to be used ?
  • Do you notice a slowdown in system response ?
  • What happens if you stop a resource-intensive process?

πŸ’‘ Tip: Pay attention to the memory usage graphs at the bottom of the window - they show the current load on RAM and the paging file.

15 of 18

PRACTICAL PART

πŸ”Ή Task 2 (Linux): Memory Usage Analysis

πŸ›  Task:

  1. Open the terminal.
  2. Run the following commands in turn:

free -h

top

vmstat

❓ Questions for analysis:

How much free and available memory does free -h show?

What is the current swap memory usage?

Are there any signs of low RAM (eg heavy swap usage )?

What does top show β€”which processes consume the most memory?

How to interpret values from vmstat ( buff , cache , si , so )?

πŸ’‘ Hint:B free pay attention to the line " available " - it shows how much memory can be used without swapping.

si and so in vmstat are the amount of data loaded into swap and unloaded from swap , respectively.

16 of 18

PRACTICAL PART

πŸ’‘ Tip: Pay attention to the "Memory Pressure " indicator - green means normal condition, yellow/red - a sign of overload.

πŸ”Ή Task 3 ( macOS ): Analyzing Memory Usage

πŸ›  Task:

  1. Open Activity Monitor ( ⌘ + Space β†’ type " Activity Monitor").
  2. Go to the Memory tab .
  3. Please note:
    • App Memory (Application Memory),
    • Wired Memory (Reserved),
    • Compressed (Compressed memory),
    • Swap Used (Swap usage).

βž• Additionally:

  • Open Terminal and run the command:

vm_stat

  • Analyze the output: page size, page ins/outs, free pages, etc.

❓ Questions for analysis: How much memory is occupied by applications?

Is swap used ? How much?

Are there any signs of low RAM?

What does vm_stat show by page? ins / outs ?

17 of 18

PRACTICAL PART

πŸ”Ή Task 4: Comparative analysis of memory work

πŸ›  Task:

Select two operating systems (for example, Windows and Linux or macOS and Linux).

Compare their memory performance using the following criteria and complete the table :

Criterion

OS 1 (…?)

OS 2 (…?)

Memory management type

Β 

Β 

Using swap

Β 

Β 

Monitoring tools

Β 

Β 

Flexibility of customization

Β 

Β 

Low Memory Response

Β 

Β 

User friendliness

Β 

Β 

πŸ“Œ Questions:

  • Where is it easier to monitor memory usage?
  • Which OS has more predictable system behavior when running low on memory?
  • Which system offers more customization options?

18 of 18

THANK YOU FOR YOUR ATTENTION