[C/C++] 메모리 구조


Memory Structure

memory_structure
  • Stack section : Function parameters, Return address, Local variables
  • Heap section : 동적 할당된 메모리
  • Data section : global and static variables (프로그램 종료 전까지 유지된다. initialized, uninitialized, read-only 세 가지로 나눌 수 있다.)
  • Text section : program code (read only)


Stack은 높은 주소에서 낮은 주소로
Heap은 낮은 주소에서 높은 주소로


TMI Zone

const 변수는 Data section에 있는 read-only로 들어가는가? : X
컴파일러에 따라서 다르며, 그냥 코드에 직접 대입하는 경우도 있고. 함수 내부에 넣으면 Stack에 들어가기도 하고.

Categories:

Updated:

Leave a comment