Hello!
I have found following strange behavior. Every time, when with() method is used, new Symbol is created and never released. Please, find sample code below.
Model:
class TestMemLeak
include Mongoid::Document
field :processed, type: Boolean, default: false
end
In controller:
def test_action
GC.start()
puts Symbol.all_symbols.size
test_mem_leak.with(write: {w: 0, j: false}){|t| t.set(processed: true) }
GC.start()
puts Symbol.all_symbols.size
end
After execuring line
test_mem_leak.with(write: {w: 0, j: false}){|t| t.set(processed: true) }
a number of symbols is always increased by one and never decreased by GC.
After replacing line above by this one:
t.set(processed: true)
issue cannot be reproduced anymore.
Tested on Ruby 2.7.2, Rails 6.1.6.
Best Regards,
Ilya