gpt4 book ai didi

ruby-on-rails - 无法分配内存

转载 作者:数据小太阳 更新时间:2023-10-29 07:00:43 26 4
gpt4 key购买 nike

由于某种原因,处理图像(carrierwave + minimagick)在服务启动后大约一周停止工作。流量或上传进程没有异常增加。一旦发生 ENOMEM 错误,一切似乎都会“锁定”,并且任何后续进程也会失败。

一旦系统出现这种行为,我该如何“拯救”它甚至阻止这种情况发生?

一些错误:

Errno::ENOMEM (Cannot allocate memory - export LANG=C && identify -ping /tmp/mini_magick20111219-18047-1dhmawm.jpg 2>&1):
app/uploaders/photo_uploader.rb:70:in `custom_thumbnail'
app/controllers/upload_controller.rb:186:in `process_upload'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'


Errno::ENOMEM (Cannot allocate memory - export LANG=C && mogrify -format jpg /tmp/mini_magick20111219-18047-1c43qpf.jpg 2>&1):
app/controllers/upload_controller.rb:186:in `process_upload'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'

...
...

Errno::ENOMEM (Cannot allocate memory - export LANG=C && mogrify -resize "120x180" -gravity "Center" -extent "120x120" /tmp/mini_magick20111219-18047-155ofje.jpg 2>&1):
app/controllers/upload_controller.rb:186:in `process_upload'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'

内存和交换空间信息:

Mem:   8193476k total,  7907152k used,   286324k free,     5968k buffers
Swap: 12396808k total, 9494924k used, 2901884k free, 180308k cached

版本信息:

  • rails 3.0.6
  • ruby 1.9.2p290
  • Apache 2.2.14
  • 乘客 3.0.9

谢谢!

最佳答案

我找不到合适的修复程序,但是一旦我使用 capistrano (cap deploy:restart) 重新启动,一切又开始运行了。

我使用 Ruby 1.9.3p194(2012-04-20 修订版 35410)

当我在 Carrierwave 中使用 mini_magick 进行操作!

时,问题就开始了
  def strip
manipulate! do |img| #where problem occurs
img.strip
img = yield(img) if block_given?
img
end
end

我的日志:

{Cannot allocate memory - identify -ping /tmp/mini_magick20121019-3337-pg50p9.jpg shared/bundle/ruby/1.9.1/gems/subexec-0.2.1/lib/subexec.rb:71:in spawn'
shared/bundle/ruby/1.9.1/gems/subexec-0.2.1/lib/subexec.rb:71:in
spawn' shared/bundle/ruby/1.9.1/gems/subexec-0.2.1/lib/subexec.rb:55:in run!'
shared/bundle/ruby/1.9.1/gems/subexec-0.2.1/lib/subexec.rb:41:in
run' shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:405:in run'
shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:399:in
run_command' shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:198:in valid?'
shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:163:in
create' shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:73:in read'
shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:134:in
block in open' shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:133:in open'
shared/bundle/ruby/1.9.1/gems/mini_magick-3.4/lib/mini_magick.rb:133:in
open' shared/bundle/ruby/1.9.1/gems/carrierwave-0.6.2/lib/carrierwave/processing/mini_magick.rb:245:in `manipulate!'

关于ruby-on-rails - 无法分配内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8566703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com