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

reflect: ArrayOf GC prog uses too much memory #10524

Closed
rsc opened this issue Apr 21, 2015 · 2 comments
Closed

reflect: ArrayOf GC prog uses too much memory #10524

rsc opened this issue Apr 21, 2015 · 2 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Apr 21, 2015

This program takes 11 GB of memory. It should use a tiny fixed amount. It's not possible to fix right now, because GC programs are disabled, but when we re-enable them, we should make this work too. This must be fixed for Go 1.5, or else we should unexport reflect.ArrayOf (new since Go 1.4).

package main

import (
    "fmt"
    "reflect"
    "runtime"
)

func main() {
    var m1, m2 runtime.MemStats
    runtime.ReadMemStats(&m1)
    reflect.ArrayOf(1e9, reflect.TypeOf((*byte)(nil)))
    runtime.ReadMemStats(&m2)
    fmt.Printf("%d\n", m2.Sys-m1.Sys)
}
@rsc rsc added this to the Go1.5 milestone Apr 21, 2015
sbinet added a commit to sbinet/golang-go that referenced this issue Apr 21, 2015
This change implements insArray and insArrayEnd directives for gcProg types
informations.

Fixes golang#10524.

Change-Id: I57773ae63c0ef6f03ea2325c21fc54d9e7bf21c6
@sbinet
Copy link
Member

sbinet commented Apr 21, 2015

I am willing to work on this (it's fun to decipher GC internals).
my WIP is over there: sbinet@dd77546

but I would need some more hand holding, I am afraid.

I started to look at runtime/mbitmaps and cmd/internal/gc/reflect.go... (gengcprog1, proggenarray proggendata, proggenarrayend and genemit seem to be the general areas where one should look at, but I don't see quite clearly how they would translate into reflect.progGC framework)

sbinet added a commit to sbinet/golang-go that referenced this issue Apr 23, 2015
This change implements insArray and insArrayEnd directives for gcProg types
informations.

Fixes golang#10524.

Change-Id: I57773ae63c0ef6f03ea2325c21fc54d9e7bf21c6
@gopherbot
Copy link
Contributor

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

@rsc rsc closed this as completed in 512f75e May 16, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

3 participants