]> Cypherpunks repositories - gostls13.git/commit
go/parser: fix memory leak by making a copy of token literals
authorRobert Griesemer <gri@golang.org>
Thu, 17 Mar 2011 22:32:29 +0000 (15:32 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 17 Mar 2011 22:32:29 +0000 (15:32 -0700)
commit39a1465d11506409902c21d25a7bc616d5e954a4
tree6a57d58668c1dc0d023b5413e9d14d8d6176461c
parent52b95970ca62033d579d2490470dcfdca986fc3d
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
src/pkg/go/parser/parser.go