Skip to content · ⁨본문 바로가기⁩

Dynamic memory: malloc, free, and realloc · ⁨동적 메모리: malloc, free 및 realloc⁩

English

Stack memory vs heap memory

  • Normal local variables live on the stack. They appear when a function starts and vanish when it returns.
  • Sometimes you need memory that outlives the function, or whose size you only know at run time.
  • That memory comes from the heap. You ask for it, and later you give it back.

한국어

스택 메모리 vs 힙 메모리

  • 정상적인 로컬 변수들은 스택에 존재합니다. 함수가 시작될 때 나타나고, 반환될 때 사라집니다.
  • 때로는 함수보다 오래 지속되는 메모리가 필요하거나, 크기를 실행 시간에만 아는 경우가 있습니다.
  • 그런 메모리는 힙에서옵니다. 요청하고, 나중에 다시 돌려주어야 합니다.

malloc은 힙 메모리 블록을 가져와 포인터를 반환합니다; free는 블록을 돌려줍니다

Handout · ⁨교재 자료⁩

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP