diff options
| author | a14m <[email protected]> | 2020-12-03 11:47:31 +0100 |
|---|---|---|
| committer | a14m <[email protected]> | 2020-12-03 11:47:31 +0100 |
| commit | b20ea269b244b448231d548fca4f068cbfce31e2 (patch) | |
| tree | 7df14a75396b93e16a5b8bfa955e9f4cad8d39b7 /CLI/ruby/lib/game_of_life | |
| parent | 289ca5c57aa8827ddd28a40e90d50d0be8c2584c (diff) | |
Fix memory leakage between current and future state
Diffstat (limited to 'CLI/ruby/lib/game_of_life')
| -rw-r--r-- | CLI/ruby/lib/game_of_life/universe.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/CLI/ruby/lib/game_of_life/universe.rb b/CLI/ruby/lib/game_of_life/universe.rb index 5b6e29a..5a25b99 100644 --- a/CLI/ruby/lib/game_of_life/universe.rb +++ b/CLI/ruby/lib/game_of_life/universe.rb @@ -3,6 +3,7 @@ require "forwardable" module GameOfLife + # Representation of the current and future state of the game of life universe class Universe extend Forwardable delegate :[] => :@current @@ -35,7 +36,7 @@ module GameOfLife @future[cell.y][cell.x] = cell.evolve!(neighbors(cell)) end end - @current = @future + @current = Marshal.load(Marshal.dump(@future)) end # Return the array of all the neighboring cells using the circular universe array |
