src/runtime: improve metadatasize calculation to avoid rounding issues

This commit is contained in:
Damian Gryski
2022-01-26 11:00:50 -08:00
committed by Ron Evans
parent 3458726234
commit 23479c92d3
+1 -1
View File
@@ -240,7 +240,7 @@ func calculateHeapAddresses() {
totalSize := heapEnd - heapStart
// Allocate some memory to keep 2 bits of information about every block.
metadataSize := totalSize / (blocksPerStateByte * bytesPerBlock)
metadataSize := (totalSize + blocksPerStateByte*bytesPerBlock) / (1 + blocksPerStateByte*bytesPerBlock)
metadataStart = unsafe.Pointer(heapEnd - metadataSize)
// Use the rest of the available memory as heap.