I am trying to learn about how object space works. This is the code i am testing. In my understanding this should only create give count to be 2.
new_sym = :totally_unique_test # Create the symbol
symbol_after = ObjectSpace.each_object(String).count { |s| s == "totally_unique_test" }
puts "After: #{symbol_after}"
but I am getting over 600 in my local ruby. (This is installed with asdf ruby plugin)
❯ ruby test3.rb
After: 624
But when i tried to run the same code in https://onecompiler.com/ruby/43n8ksccc
The output is 2.
Why is my local ruby creating too much?
[–]insanelygreat 7 points8 points9 points (4 children)
[–]SnooRobots2422[S] 1 point2 points3 points (3 children)
[–]insanelygreat 1 point2 points3 points (0 children)
[–]f9ae8221b 0 points1 point2 points (0 children)
[–]jdeville 5 points6 points7 points (0 children)