Skip to content

Commit 8068419

Browse files
committed
runtime: heapptr only needs to be initialized once
There is no need to initialize it twice.
1 parent 9b3eb3f commit 8068419

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/runtime/gc_leaking.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// Ever-incrementing pointer: no memory is freed.
14-
var heapptr = heapStart
14+
var heapptr uintptr
1515

1616
// Total amount allocated for runtime.MemStats
1717
var gcTotalAlloc uint64
@@ -93,7 +93,8 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
9393
}
9494

9595
func initHeap() {
96-
// preinit() may have moved heapStart; reset heapptr
96+
// Initialize this bump-pointer allocator to the start of the heap.
97+
// Needed here because heapStart may not be a compile-time constant.
9798
heapptr = heapStart
9899
}
99100

0 commit comments

Comments
 (0)