Reviewed by Aditya Kumar · Last reviewed 2026-08-08
To check memory on a Linux laptop, the primary commands are free h for a summary of system memory usage and top (or htop ) to monitor per process memory consumption in real time. Mechanics / "Why"…
This easy-level General/Other question appears frequently in data engineering interviews at companies like Coforge. While less common, it tests deeper understanding that distinguishes strong candidates.
Start by clearly defining the core concept being asked about. Interviewers want to see that you understand the fundamentals before diving into implementation details. Structure your answer with a definition, then explain the practical application with a concise example. The expert answer includes a code example that demonstrates the implementation pattern.
To check memory on a Linux laptop, the primary commands are free -h for a summary of system memory usage and top (or htop) to monitor per-process memory consumption in real-time.
* free -h: This command provides a human-readable summary of total, used, free, shared, buff/cache, and available memory. The available column is crucial: it represents memory that can be allocated to new processes without the system needing to swap. This includes free memory plus reclaimable buff/cache.
* top / htop: These interactive tools display a dynamic view of running processes. Key memory metrics include VIRT (virtual memory size), RES (resident set size – actual physical memory used), and SHR (shared memory). They are invaluable for identifying memory-intensive applications or processes that might be leaking memory.
* /proc/meminfo: This file provides the most detailed, kernel-level information about memory usage, serving as the source for free. It lists various memory statistics like MemTotal, MemFree, Buffers, Cached, SwapTotal, etc.
* vmstat: Offers a report on virtual memory statistics, including memory paging (swapping in/out), which indicates memory pressure.
* ps aux --sort=-%mem | head -n 10: Lists the top 10 processes by memory usage, useful for quickly pinpointing memory hogs.
Understanding the available vs. free distinction is critical. A system might show very little free memory but plenty available because the kernel uses inactive memory for file caches (buff/cache), which can be instantly reclaimed. This is efficient.
free -h
total used free shared buff/cache available
Mem: 15Gi 5.0Gi 1.2Gi 200Mi 8.8Gi 9.5Gi
Swap: 2.0Gi 0.0Bi 2.0Gi
In this example, only 1.2Gi is free, but 9.5Gi is available for new applications, indicating healthy memory usage. For data engineers, this distinction is vital when troubleshooting Out-Of-Memory (OOM) errors in Spark executors or other memory-intensive jobs, where the system might be swapping heavily despite appearing to have "used" memory for caching.
When working with containers (e.g., Docker, Kubernetes for Spark executors), remember that free -h inside a container might show the host's memory. To see the container's actual memory limits and usage, you'd inspect cgroup metrics, typically found in /sys/fs/cgroup/memory/memory.stat or using container orchestration tools.
Pro-Move: 'In K8s we use resource limits; free -h shows host. For pods: kubectl top pod. Saw OOM when limits too low.'
Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.
According to DataEngPrep.tech, this is one of the most frequently asked General/Other interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.