1

深入理解 Go | 内存管理:栈

 2 years ago
source link: https://ictar.github.io/2020/04/26/dive-into-go-memory-stack/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

深入理解 Go | 内存管理:栈

发表于

2020-04-26 更新于 2021-01-26

阅读次数: 10 Disqus: 0 Comments

基于 Go 1.14

应用程序的内存分为: * 堆区。程序在运行期间可以主动向堆区申请内存,这些内存由内存分配器分配并由垃圾收集器负责回收。 * 栈区。由编译器自动进行分配和释放,存储函数的入参以及局部变量。这些参数会随着函数的创建而创建,函数的返回而消亡。

Go 语言使用 goroutine 作为执行上下文,而 goroutine 的初始栈内存时 2KB,比线程小很多。

Go 1.3 开始使用的栈策略,不再将栈分段。

请言小午吃个甜筒~~

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK