Last active
April 25, 2019 21:11
-
-
Save Edouard-chin/a1b5d86b584c1f00090599e0360844eb to your computer and use it in GitHub Desktop.
Weird
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'psych' | |
class Foo | |
def value | |
return @value if defined?(@value) | |
@value = { | |
fix_encoding('foo') => fix_encoding('a' * 24), | |
fix_encoding('bar') => fix_encoding('b' * 24), | |
} | |
end | |
def forgetting_assignment | |
Psych.dump(value) | |
end | |
def fix_encoding(string) | |
string.encode(Encoding::ASCII).gsub(/bla/i, '') | |
end | |
end | |
4.times { GC.start } | |
GC.disable | |
before_last_change = Foo.new | |
before_last_change.forgetting_assignment | |
p before_last_change.value | |
4.times { GC.start } | |
p before_last_change.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment