R14 - memory quota exceeded

I have memory issues for my Heroku hosted application. I am using a working one and only 1x default. The app uses Ruby 2.0 and Rails 4.1.4 with a unicorn as its web server.

Here is the unicorn config file.

worker_processes Integer(ENV["WEB_CONCURRENCY"] || 2)
timeout 30
preload_app true

before_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end 

after_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

      

I am getting R14 memory error for no reason. There are no requests to the application, but as you can see from the screenshot, the memory used doubles in a short amount of time.

Aug 21 00:47:22 ABC heroku/web.1:  source=web.1 dyno=heroku.27639500.25827f7d-f927-465a-898d-dd87d4376efb sample#load_avg_1m=0.35 
Aug 21 00:47:22 ABC heroku/web.1:  source=web.1 dyno=heroku.27639500.25827f7d-f927-465a-898d-dd87d4376efb sample#memory_total=222.71MB sample#memory_rss=222.70MB sample#memory_cache=0.01MB sample#memory_swap=0.00MB sample#memory_pgpgin=62101pages sample#memory_pgpgout=5088pages 
Aug 21 00:47:43 ABC heroku/web.1:  source=web.1 dyno=heroku.27639500.25827f7d-f927-465a-898d-dd87d4376efb sample#load_avg_1m=0.25 
Aug 21 00:47:43 ABC heroku/web.1:  source=web.1 dyno=heroku.27639500.25827f7d-f927-465a-898d-dd87d4376efb sample#memory_total=588.86MB sample#memory_rss=511.95MB sample#memory_cache=0.01MB sample#memory_swap=76.91MB sample#memory_pgpgin=156028pages sample#memory_pgpgout=24968pages 
Aug 21 00:47:43 ABC heroku/web.1:  Process running mem=588M(115.0%) 
Aug 21 00:47:43 ABC heroku/web.1:  Error R14 (Memory quota exceeded) 
Aug 21 00:48:04 ABC heroku/web.1:  source=web.1 dyno=heroku.27639500.25827f7d-f927-465a-898d-dd87d4376efb sample#load_avg_1m=0.17 
Aug 21 00:48:04 ABC heroku/web.1:  source=web.1 dyno=heroku.27639500.25827f7d-f927-465a-898d-dd87d4376efb sample#memory_total=177.77MB sample#memory_rss=83.40MB sample#memory_cache=0.00MB sample#memory_swap=94.36MB sample#memory_pgpgin=181821pages sample#memory_pgpgout=160469pages 

      

Thank!

+3


source to share


1 answer


Optimizing Ruby Garbage collection can help a lot with saving used memory on heroku instance. If Ruby runs the GC more frequently, it has a slight disadvantage in burning up some CPU cycles, but will reduce memory usage.

Especially high (default) values RUBY_GC_HEAP_GROWTH_FACTOR

can cause Error R14 (Memory quota exceeded)

.



The default is 1.8

, which means that if the heap needs to be expanded, it will grow by 80%. You can try to omit this value by anything between 1.1

and 1.5

.

0


source







All Articles