Memory Management
Memory management is the process by which a computer system allocates and deallocates memory resources to running programs and processes, ensuring efficient uti...
Memory management는 operating system (OS)에서 process와 application에 memory space를 할당하고 해제하는 기본적인 process입니다. 주요 목표는 사용 가능한 physical memory (RAM)를 효율적으로 사용하고, process들이 서로의 memory region을 방해하지 않도록 하며, 종종 사용 가능한 physical RAM보다 큰 일관된 memory address space를 application에 제공하는 것입니다. 주요 기술에는 partitioning (memory를 fixed 또는 variable-sized block으로 나누는 것), paging (memory와 process를 fixed-size page와 frame으로 나누어 non-contiguous allocation을 허용하는 것), 그리고 segmentation (memory를 program module에 해당하는 logical segment로 나누는 것)이 포함됩니다. Virtual memory는 secondary storage (hard drive 또는 SSD와 같은)를 RAM의 overflow로 사용하여 사용 가능한 memory를 확장하는 중요한 개념입니다. Physical memory가 가득 차면, 덜 자주 사용되는 page는 disk (swap space)로 swap out되고 필요할 때 다시 load됩니다. 이를 통해 시스템은 일반적으로 physical RAM이 허용하는 것보다 더 많은 application을 실행할 수 있으며 memory protection을 제공합니다. Contiguous allocation을 위한 First-Fit, Best-Fit, Worst-Fit과 같은 memory management algorithm과 virtual memory의 page replacement를 위한 Least Recently Used (LRU) 또는 First-In, First-Out (FIFO)와 같은 algorithm은 performance를 최적화하고 fragmentation (internal 및 external)을 최소화하기 위해 사용됩니다.
graph LR
Center["Memory Management"]:::main
Rel_advanced_propulsion_systems["advanced-propulsion-systems"]:::related -.-> Center
click Rel_advanced_propulsion_systems "/terms/advanced-propulsion-systems"
Rel_process_management["process-management"]:::related -.-> Center
click Rel_process_management "/terms/process-management"
Rel_garbage_collection["garbage-collection"]:::related -.-> Center
click Rel_garbage_collection "/terms/garbage-collection"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 5살도 이해할 수 있게 설명
Memory management는 컴퓨터의 단기 기억 (RAM)을 위한 사서와 같아서, 각 프로그램이 작동할 자신만의 공간을 확보하고 다른 프로그램의 것을 망치지 않도록 합니다.
🤓 Expert Deep Dive
현대의 메모리 관리 기법은 CPU가 생성하는 가상 주소를 RAM의 물리 주소로 변환하는 하드웨어 구성 요소인 MMU(Memory Management Unit)에 크게 의존합니다. 운영체제의 페이지 테이블에 의해 관리되는 이 변환 과정은 가상 메모리, 메모리 보호, 효율적인 메모리 공유를 가능하게 합니다. 페이지 폴트는 요청된 페이지가 물리 메모리에 없을 때 발생하며, 운영체제의 페이지 교체 알고리즘을 트리거하여 보조 저장 장치에서 해당 페이지를 가져옵니다. 고급 기법으로는 메모리 맵 파일, 효율적인 프로세스 포킹을 위한 Copy-on-Write 메커니즘, 멀티프로세서 시스템에서 메모리 접근 지연 시간을 최적화하기 위한 NUMA(Non-Uniform Memory Access) 인식이 있습니다. 보안 측면에서도 중요한 의미를 가지는데, 버퍼 오버플로우나 Use-after-free 오류와 같은 취약점은 종종 잘못된 메모리 관리에서 비롯되어 잠재적인 악용으로 이어질 수 있습니다. Java나 Python과 같은 관리형 런타임에서 널리 사용되는 가비지 컬렉션은 더 이상 사용되지 않는 객체가 차지하는 메모리를 회수하는 또 다른 형태의 자동 메모리 관리입니다.