Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/race: runaway memory consumption #14533

Closed
dvyukov opened this issue Feb 26, 2016 · 1 comment
Closed

runtime/race: runaway memory consumption #14533

dvyukov opened this issue Feb 26, 2016 · 1 comment

Comments

@dvyukov
Copy link
Member

dvyukov commented Feb 26, 2016

The following benchmark consumes unlimited amount of memory:

func BenchmarkSyncLeak(b *testing.B) {
    const (
        G = 1000
        S = 1000
        H = 10
    )
    var wg sync.WaitGroup
    wg.Add(G)
    for g := 0; g < G; g++ {
        go func() {
            defer wg.Done()
            hold := make([][]uint32, H)
            for i := 0; i < b.N; i++ {
                a := make([]uint32, S)
                atomic.AddUint32(&a[rand.Intn(len(a))], 1)
                hold[rand.Intn(len(hold))] = a
            }
            _ = hold
        }()
    }
    wg.Wait()
}

The main cause is that race runtime does not wipe stale synchronization objects from heap memory blocks.

@dvyukov dvyukov self-assigned this Feb 26, 2016
@dvyukov dvyukov added this to the Go1.7 milestone Feb 26, 2016
@gopherbot
Copy link

CL https://golang.org/cl/19970 mentions this issue.

@golang golang locked and limited conversation to collaborators May 3, 2017
@rsc rsc unassigned dvyukov Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants