Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot allocate memory - grep #206

Open
leoluchini opened this issue Apr 18, 2023 · 1 comment
Open

Cannot allocate memory - grep #206

leoluchini opened this issue Apr 18, 2023 · 1 comment

Comments

@leoluchini
Copy link

leoluchini commented Apr 18, 2023

Hi,

I'm doing a ruby migration (3.0.5) in the current system and when I run the specs I got an error. This call is inside a service and is called many times and couldn't find the explanation for this error

Failure/Error: @image_optim ||= ImageOptim.new(image_optim_config)
Errno::ENOMEM:
Cannot allocate memory - grep
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim/cmd.rb:44:in ``'
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim/cmd.rb:44:in `capture'
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim/config.rb:220:in `processor_count'
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim/config.rb:120:in `threads'
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim.rb:88:in `block in initialize'
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim.rb:87:in `each'
# /usr/local/bundle/gems/image_optim-0.31.3/lib/image_optim.rb:87:in `initialize'

This is the image_optim_config

{
  :skip_missing_workers=>true,
  :nice=>10,
  :advpng=>false,
  :gifsicle=>false,
  :jhead=>false,
  :jpegoptim=>false,
  :allow_lossy=>true,
  :oxipng=>false, 
  :jpegrecompress=>false, 
  :jpegtran=>{
    :copy_chunks=>false, 
    :progressive=>true, 
    :jpegrescan=>false
  }, 
  :optipng=>false, 
  :pngcrush=>false, 
  :pngout=>false, 
  :pngquant=>false, 
  :svgo=>false
}

I'm using version 0.31.3 for image_optim

@toy
Copy link
Owner

toy commented Apr 20, 2023

The command that is fails with the error is very simple grep -c processor /proc/cpuinfo and the error is clearly stating that there is no memory to run the command. So first question is if system is really low on memory, maybe worth checking what free (free -m) says before initialising ImageOptim. Otherwise maybe per process resource limit is reached then it is worth checking ruby process memory consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants