mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
src/runtime: improve metadatasize calculation to avoid rounding issues
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user