Skip to content

Commit e288226

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

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/gc_blocks.go

+4
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
378378
if nextAlloc > maxBlock {
379379
maxBlock = nextAlloc - 1
380380
}
381+
if heapScanCount == 2 {
382+
// if we had to do a GC to find this allocation, reset nextAlloc to the start of the heap
383+
nextAlloc = 0
384+
}
381385
return pointer
382386
}
383387
}

0 commit comments

Comments
 (0)