mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 19:13:40 +08:00
f4d06f195d
We are investigating a memory leak in Sidekiq and saw the following line when comparing heap dumps over time. `Allocated IMEMO 14775 objects of size 591000/7389528 (in bytes) at: /var/www/discourse/app/jobs/onceoff/onceoff.rb:36` That line in question was doing a `.select { |klass| klass < self }` on `ObjectSpace.each_object(Class)`. This for some reason is allocating a whole bunch of `IMEMO` objects which are instruction sequence objects. Instead of diving deeper into why this might be leaking, we can just save our time by switching to an implementation that is more efficient and does not require looping through a ton of objects.
13 lines
370 B
Ruby
13 lines
370 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe ::Jobs::Onceoff do
|
|
it "can run all once off jobs without errors" do
|
|
# Load all once offs
|
|
Dir[Rails.root + "app/jobs/onceoff/*.rb"].each do |f|
|
|
require_relative "../../app/jobs/onceoff/" + File.basename(f)
|
|
end
|
|
|
|
described_class.onceoff_job_klasses.each { |job| job.new.execute_onceoff(nil) }
|
|
end
|
|
end
|