go/parser: fix memory leak by making a copy of token literals
The scanner returns slices into the original source for token values. If those slices are making it into the AST and from there into other long-living data structures (e.g. godoc search), references to the original source are kept around involuntarily. For the current godoc and source tree, this change reduces memory consumption after indexing and before GC by ~92MB or almost 30%, and by ~10MB after GC (or about 6%). R=rsc CC=golang-dev https://golang.org/cl/4273072
Showing
Please
register
or
sign in
to comment