mirror of
https://github.com/golang/go
synced 2024-11-02 15:37:45 +00:00
runtime: free stacks of Gdead goroutines at GC time
We could probably free the G structures as well, but for the allg list. Leaving that for another day. Fixes #8287 LGTM=rsc R=golang-codereviews, dvyukov, khr, rsc CC=golang-codereviews https://golang.org/cl/145010043
This commit is contained in:
parent
6fb9d50d15
commit
92eb1e1600
1 changed files with 9 additions and 1 deletions
|
@ -806,8 +806,16 @@ runtime·shrinkstack(G *gp)
|
|||
{
|
||||
uintptr used, oldsize, newsize;
|
||||
|
||||
if(runtime·readgstatus(gp) == Gdead)
|
||||
if(runtime·readgstatus(gp) == Gdead) {
|
||||
if(gp->stack.lo != 0) {
|
||||
// Free whole stack - it will get reallocated
|
||||
// if G is used again.
|
||||
runtime·stackfree(gp->stack);
|
||||
gp->stack.lo = 0;
|
||||
gp->stack.hi = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(gp->stack.lo == 0)
|
||||
runtime·throw("missing stack in shrinkstack");
|
||||
|
||||
|
|
Loading…
Reference in a new issue