mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
ScreenshotWorker: garbage collection improvements
This commit is contained in:
parent
a75a02d653
commit
7c4ffcb413
1 changed files with 10 additions and 0 deletions
|
@ -41,6 +41,8 @@ class ScreenshotWorker
|
||||||
#else
|
#else
|
||||||
# raise
|
# raise
|
||||||
#end
|
#end
|
||||||
|
ensure
|
||||||
|
screenshot.unlink
|
||||||
end
|
end
|
||||||
|
|
||||||
img_list = Magick::ImageList.new
|
img_list = Magick::ImageList.new
|
||||||
|
@ -51,6 +53,7 @@ class ScreenshotWorker
|
||||||
|
|
||||||
img_list.new_image(img_list.first.columns, img_list.first.rows) { self.background_color = "white" }
|
img_list.new_image(img_list.first.columns, img_list.first.rows) { self.background_color = "white" }
|
||||||
img = img_list.reverse.flatten_images
|
img = img_list.reverse.flatten_images
|
||||||
|
img_list.destroy!
|
||||||
|
|
||||||
user_screenshots_path = File.join SCREENSHOTS_PATH, username
|
user_screenshots_path = File.join SCREENSHOTS_PATH, username
|
||||||
screenshot_path = File.join user_screenshots_path, File.dirname(path)
|
screenshot_path = File.join user_screenshots_path, File.dirname(path)
|
||||||
|
@ -68,7 +71,14 @@ class ScreenshotWorker
|
||||||
new_img.write(File.join(user_screenshots_path, "#{path}.#{res}.jpg")) {
|
new_img.write(File.join(user_screenshots_path, "#{path}.#{res}.jpg")) {
|
||||||
self.quality = 90
|
self.quality = 90
|
||||||
}
|
}
|
||||||
|
new_img.destroy!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
img.destroy!
|
||||||
|
|
||||||
|
GC.start full_mark: true, immediate_sweep: true
|
||||||
|
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
sidekiq_retries_exhausted do |msg|
|
sidekiq_retries_exhausted do |msg|
|
||||||
|
|
Loading…
Add table
Reference in a new issue