Skip to content

Channel creation leaks heap memory since 7c59a8fa31c3 #1676

@davecheney

Description

@davecheney
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. compile this code

package main

import (
    "runtime"
    "fmt"
    "time"
)

func stats() {
    for {
        <-time.After(3e9)
        fmt.Printf("CurrAlloc: %d, HeapAlloc: %d\n", runtime.MemStats.Alloc, runtime.MemStats.HeapAlloc)
    }
}

func main() {
    go stats()
    for {
        <-time.After(7e9)
        runtime.GC()
    }
}

2. run and wait (10 mins is sufficient) 6g leaky.go ; 6l leaky.6 ; ./6.out

What is the expected output?

CurrAlloc should stabalise, eg

CurrAlloc: 345224, HeapAlloc: 344784
CurrAlloc: 345696, HeapAlloc: 344784
CurrAlloc: 346200, HeapAlloc: 344784
CurrAlloc: 345288, HeapAlloc: 344784
CurrAlloc: 345792, HeapAlloc: 344784
CurrAlloc: 345224, HeapAlloc: 344784
CurrAlloc: 345696, HeapAlloc: 344784
CurrAlloc: 345192, HeapAlloc: 344784
CurrAlloc: 345696, HeapAlloc: 344784

What do you see instead?

CurrAlloc and VSS of the process grow without bounds

Which compiler are you using (5g, 6g, 8g, gccgo)?

Confirmed on 8g and 6g

Which operating system are you using?

Darwin and Linux

Which revision are you using?  (hg identify)

All revision since http://code.google.com/p/go/source/detail?r=7c59a8fa31c3 are believed
affected.

Please provide any additional information below.

I believe the change which introduced this regression was
http://golang.org/cl/4291064. It is possible that the changes made in this CL
to improve channel allocation were not backed by a corresponding change in deallocation.

This is related to the issue https://golang.org/issue/1537 and
additional discussion at
http://groups.google.com/group/golang-nuts/browse_thread/thread/93b42ac1f888a615

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions