Memory and Performance: Virtual Memory
In previous posts, we discovered how being memory-aware improves performance. The array-based BST was ~53% faster than its pointer-based counterpart, and we saw how garbage collection algorithms can spend 85% of their time stalled on memory accesses. But, there’s a fundamental layer we need to explore the virtual memory. Every memory access in a program goes through virtual memory translation. This blog post will try to explain: Why this layer exists? How it works? What is virtual memory? Processes in a system share the CPU and main memory with other processes. With sharing comes challenges. As demand for the CPU increases, processes slow down but, if too many processes need too much memory, then some of them will simply not be able to run. Memory is also vulnerable to corruption if some process writes to the memory used by another process that process might fail in some unpredictable fashion totally unrelated to the program logic. ...