본문 바로가기

Computer Science/Operating System

메모리 데이터 저장 구역 (machine code, globals, heap, stack)

메모리 안에는 데이터 저장되는 구역이 나뉘어져 있습니다.

머신 코드 영역에는 우리 프로그램이 실행될 때 그 프로그램이 컴파일된 바이너리가 저장됩니다.

글로벌 영역에는 프로그램 안에서 저장된 전역 변수가 저장됩니다.

 영역에는 malloc으로 할당된 메모리의 데이터가 저장됩니다.

스택에는 프로그램 내의 함수와 관련된 것들이 저장됩니다.

 

https://www.boostcourse.org/cs112/lecture/119033?isDesc=false 

 

모두를 위한 컴퓨터 과학 (CS50 2019)

부스트코스 무료 강의

www.boostcourse.org

 

 

Heap overflow and Stack overflow

힙 영역이 과도하게 점유되면 힙 오버플로우

스택 영억이 과도하게 점유되면 스택 오버플로우가 발생함

 

Heap Overflow: Heap is a region of process’s memory which is used to store dynamic variables. These variables are allocated using malloc() and calloc() functions and resize using realloc() function, which are inbuilt functions of C. These variables can be accessed globally and once we allocate memory on heap it is our responsibility to free that memory space after use.

 

 

Stack Overflow: Stack is a special region of our process’s memory which is used to store local variables used inside the function, parameters passed through a function and their return addresses. Whenever a new local variable is declared it is pushed onto the stack. All the variables associated with a function are deleted and memory they use is freed up, after the function finishes running. The user does not have any need to free up stack space manually. Stack is Last-In-First-Out data structure.

 

https://www.geeksforgeeks.org/heap-overflow-stack-overflow/

 

Heap overflow and Stack overflow - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

 

'Computer Science > Operating System' 카테고리의 다른 글

Kernel  (0) 2022.02.06