mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-10 12:28:11 +00:00
Fix virtual arena memory block overcommit bug #5821
This commit is contained in:
@@ -141,9 +141,9 @@ arena_alloc_unguarded :: proc(arena: ^Arena, size: uint, alignment: uint, loc :=
|
||||
|
||||
needed := mem.align_forward_uint(size, alignment)
|
||||
needed = max(needed, arena.default_commit_size)
|
||||
block_size := max(needed, arena.minimum_block_size)
|
||||
block_size := max(needed, arena.minimum_block_size) + alignment
|
||||
|
||||
new_block := memory_block_alloc(needed, block_size, alignment, {}) or_return
|
||||
new_block := memory_block_alloc(needed, block_size) or_return
|
||||
new_block.prev = arena.curr_block
|
||||
arena.curr_block = new_block
|
||||
arena.total_reserved += new_block.reserved
|
||||
|
||||
@@ -154,7 +154,7 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint,
|
||||
|
||||
pmblock.committed = platform_total_commit
|
||||
block.committed = pmblock.committed - base_offset
|
||||
|
||||
assert(block.committed <= block.reserved)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -174,7 +174,7 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint,
|
||||
err = .Out_Of_Memory
|
||||
return
|
||||
}
|
||||
assert(block.committed <= block.reserved)
|
||||
|
||||
do_commit_if_necessary(block, size, default_commit_size) or_return
|
||||
|
||||
data = block.base[block.used+alignment_offset:][:min_size]
|
||||
|
||||
Reference in New Issue
Block a user