Skip to content

Commit ee4882d

Browse files
committed
runtime: reset nextAlloc to the start of the heap after a GC
1 parent f503ebf commit ee4882d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/gc_blocks.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
381381
if nextAlloc > maxBlock {
382382
maxBlock = nextAlloc - 1
383383
}
384+
if heapScanCount == 2 {
385+
// if we had to do a GC to find this allocation, reset nextAlloc to the start of the heap
386+
nextAlloc = 0
387+
}
384388
return pointer
385389
}
386390
}

0 commit comments

Comments
 (0)