aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/stack.c
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-09-17 13:25:46 -0700
committerKeith Randall <khr@golang.org>2014-09-17 13:25:46 -0700
commit92eb1e1600c3770d2ec669a8d6b7947cac551305 (patch)
treeac2939274179d7e2fb067fde49a468ac467051d5 /src/runtime/stack.c
parent6fb9d50d154c4a8ac4db11e91a3d221322859191 (diff)
downloadgo-92eb1e1600c3770d2ec669a8d6b7947cac551305.tar.xz
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
Diffstat (limited to 'src/runtime/stack.c')
-rw-r--r--src/runtime/stack.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/stack.c b/src/runtime/stack.c
index b38ee31d48..95a5a123d9 100644
--- a/src/runtime/stack.c
+++ b/src/runtime/stack.c
@@ -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");