Skip to content

Commit

Permalink
Only expand heap with minimal required
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhoerberg committed Aug 15, 2023
1 parent e2205b3 commit 0b1ade3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/amq/protocol/table.cr
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ module AMQ

private def ensure_capacity(size : Int)
if @bytesize + size > @capacity
capacity = Math.pw2ceil(@bytesize + size)
@buffer = GC.realloc(@buffer, capacity)
@capacity = capacity
required_capacity = @bytesize + size
@buffer = GC.realloc(@buffer, required_capacity)
@capacity = required_capacity
end
end

Expand Down

0 comments on commit 0b1ade3

Please sign in to comment.