일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 구글 클라우드
- GCP
- Dataproc
- 쿠버네티스
- 머신러닝
- 딥러닝
- DataFlow
- 자격증
- 코세라
- 구글
- coursera
- docker
- 클라우드
- 도커
- aws
- cloud
- 클라우드 자격증
- 네트워크
- 구글클라우드서밋
- AWS #빅데이터 #분석 #데이터
- go
- 구글클라우드
- 마이크로서비스
- nnictl
- golang
- 구글클라우드플랫폼
- Kubernest
- Associate
- cdk
- Today
- Total
JD의 블로그
1. Stack vs Heap 본문
1. About Main Memory
Memory is divided into smaller addressable units that are called as bytes. Every bytes have its own address. The entire memory is not used as a single unit, but it is divided into manageble pices, that are called as segment.
2. How a Program use memory
Main mamory is divided into three sections : code section, Stack, and Heap.
If I have a program file on the hard disk and if i want to run this program, so the machine code of the program should be brought inside the main memory.
So, the area that is occupied by the program, in the main memory, is called as "Code Section" that not be fixed.
Once it is loaded, the CPU will start executing the program, and this program will utilize the remaining memory as divided into stack and heap.
data in main function is called "activation record of main function", which is created into the Stack.
Number of bytes taken by integer depends on the compiler, and the operating system, and the hardware.
3. Static Allocation
How many bytes of memory is required by the function was decided at compile time. The size of the memory is a static value. So, when everything is done at compile time or before run time, it is called static.
When I want to run sequence of programs, the machine code of these programs will be copied in code section.
These require variables, so the memory for variables will be allocated in stack. Stack memory behaves llike a stck during the function call.
4. Dynamic Allocation
How heap memory is utilized by a program.
Heap means what? Piling up! If the things are kept one above another, or just randomly, we use the term Heap.
So Heap is used in 2 cases.
[1] If the things are properly organised like a tower-like thing
[2] if it is not organised and also it's looking like a tower, then also we call it as Heap.
Here , Heap is the term used for unorganized memory.
Heap memory should be treated like a resource.
Program can't directly access heap memory. (only possible by using pointer!)
"new" means memory is allocated in heap.
'-프로그래밍 언어 > 알고리즘&자료구조' 카테고리의 다른 글
5. Matrices[1] - Diagonal Matrix (0) | 2019.09.19 |
---|---|
4. Time and Space complexity (0) | 2019.09.18 |
3. ADT(Abstract Data Type) (0) | 2019.09.18 |
2. Physical data structure & Logical data structure (0) | 2019.09.18 |
[Algorithm & Data structure] Introduction (0) | 2019.09.16 |