Skip to content

Commit

Permalink
runtime: heapptr only needs to be initialized once
Browse files Browse the repository at this point in the history
There is no need to initialize it twice.
  • Loading branch information
aykevl committed Nov 18, 2024
1 parent 9b3eb3f commit 8068419
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/gc_leaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

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

// Total amount allocated for runtime.MemStats
var gcTotalAlloc uint64
Expand Down Expand Up @@ -93,7 +93,8 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
}

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

Expand Down

0 comments on commit 8068419

Please sign in to comment.