From b20ea269b244b448231d548fca4f068cbfce31e2 Mon Sep 17 00:00:00 2001 From: a14m Date: Thu, 3 Dec 2020 11:47:31 +0100 Subject: Fix memory leakage between current and future state --- CLI/ruby/lib/game_of_life/universe.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'CLI/ruby/lib') 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 -- cgit v1.2.3