Go Heap & Stack Memory Allocation

김영석
Jul 18, 2022

In a nutshell

Go uses 2 types of memory allocation methodology.

Stack memory allocation

→ this is for memory allocation exclusively used by function or method call.

Heap memory allocation

→ This happens when the Go compiler determines that pointers won’t live exclusively in function/method call stack. And this decision is made by the process of “Escape Analysis”.

In general, the stack memory allocation is much faster and cheaper than the heap memory allocation, so be careful of using pointers in function/method.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

김영석
김영석

Written by 김영석

I love problem solving and hate repetition of tedious tasks. I like automating, streamlining, optimizing, things.

No responses yet

Write a response