Skip to content

Commit 8d929ad

Browse files
committed
runtime: zero freed memory
This helps to find bugs in the GC. It does have a performance impact so it's only enabled when asserts are enabled.
1 parent dbde790 commit 8d929ad

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/runtime/gc_blocks.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ func (b gcBlock) markFree() {
168168
if gcAsserts && b.state() != blockStateFree {
169169
runtimePanic("gc: markFree() was not successful")
170170
}
171+
if gcAsserts {
172+
*(*[wordsPerBlock]uintptr)(unsafe.Pointer(b.address())) = [wordsPerBlock]uintptr{}
173+
}
171174
}
172175

173176
// unmark changes the state of the block from mark to head. It must be marked

0 commit comments

Comments
 (0)