Skip to content

Instantly share code, notes, and snippets.

Created Apr 12, 2013
What would you like to do?
Memory Leak of Golang
Hi all,
I am studying Go, and find that it is very interesting and "battery" included.
In this mail, I want to ask something about the garbage collection rules of Go.
For example, in the following program.
package main
import (
func DoSomeThing(){
a := make([][]interface{},10000)
for i:=0;i<len(a);i++{
a[i] = make([]interface{},10000)
for j:=0;j<len(a[i]);j++{
a[i][j] = rand.Float64()
func main() {
for {
It will allocate 1.6 GB memory on my windows x64 machine with go1.1 beta2.
I am confused that why the memory allocated by DoSometThing() is not freed?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment