Golang - Stack & Heap

常常在社群里面看到从其他程式语言转来用Go会有的问题
这些是找到的资料跟总结
同步更新在github上
https://github.com/whitefloor/coding-interview-university-reading-notes-use-golang

Stack and Heap

一般的Stack & Heap

https://nwpie.blogspot.com/2017/05/5-stack-heap.htmlhttps://medium.com/@yauhsienhuang/stack-%E8%88%87-heap-%E6%9C%89%E4%BD%95%E5%B7%AE%E5%88%A5-acdcc11263a0

Golang的Stack & Heap

https://golang.org/doc/faq#stack_or_heaphttp://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/index.html#stack_heap_varshttps://medium.com/eureka-engineering/understanding-allocations-in-go-stack-heap-memory-9a2631b5035dhttps://stackoverflow.com/questions/10866195/stack-vs-heap-allocation-of-structs-in-go-and-how-they-relate-to-garbage-collec

总结

别用中文翻译去记,很难翻译而且很难记

Stack

静态记忆体配置

  A call stack is a LIFO stack data structure that stores arguments, local variables, and other data tracked as a thread executes functions

将可预期的变数或是function等...的处理方法

Heap

动态记忆体配置

将不可预期的变数或资料分配管理,且会被GC回收的处理方法

Golang的Stack & Heap

Go在使用上并没有提到Stack or Heap  只会在GC(garbage-collected)内遵循一套严格的规则进行处理If you need to know where your variables are allocated pass the "-m" gc flag to "go build" or "go run" (e.g., go run -gcflags -m app.go).

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章