THINK FIRST·CODE LATER

← All labs

Linux in practice: where does the memory go?

Problem

On a Linux machine (a VM, WSL or a cloud instance), investigate memory management in a running system. Record the commands and outputs.

  1. free -h and cat /proc/meminfo | head -20: explain total, used, free, available, buffers/cache. Why is "free" usually small on a healthy system?
  2. Start a Java or Python process and inspect /proc/<pid>/maps (or pmap -x <pid>): identify the code, heap, stack and shared-library regions. Which libraries are shared with other processes?
  3. getconf PAGESIZE, cat /proc/buddyinfo and grep Huge /proc/meminfo: what is the page size, how many free blocks of each order exist, and are transparent huge pages enabled (cat /sys/kernel/mm/transparent_hugepage/enabled)?
  4. Run a container with a memory limit: docker run --rm -m 256m python:3-slim python -c "a = bytearray(512*1024*1024)". What happens? Check docker inspect / dmesg for the OOM kill and explain exit code 137.
  5. Write 5–8 sentences: how would you choose memory requests and limits for the EdgeCampus inference service, and what would you monitor?

Work it out on paper, in a document or here, then compare with the model answer. Your answer stays in your browser — it is never sent to or stored on the server.