title: Unicorn cannot allocate memory
body: <p>i need your help!</p>
  
  <p>I have deployed my Rails app in Ubuntu 12.04, using Nginx, MySQL, Solr and Unicorn.</p>
  
  <p>Every mentioned service is started, instead of unicorn, which says following:</p>
  
  <blockquote>
    <p>I, [2013-02-11T16:10:20.187989 #27547]  INFO -- : Refreshing Gem list
    I, [2013-02-11T16:10:52.159198 #27547]  INFO -- : unlinking existing
    socket=/var/www/staging/shared/unicorn.sock I,
    [2013-02-11T16:10:52.159488 #27547]  INFO -- : listening on
    addr=/var/www/staging/shared/unicorn.sock fd=12 E,
    [2013-02-11T16:10:52.161513 #27547] ERROR -- : Cannot allocate memory
    - fork(2) (Errno::ENOMEM) /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:496:in
    <code>fork'
    /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:496:in
    </code>spawn_missing_workers'
    /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:142:in
    <code>start'
    /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/bin/unicorn_rails:209:in
    </code>'
    /var/www/staging/shared/gems/ruby/1.9.1/bin/unicorn_rails:23:in <code>load'
    /var/www/staging/shared/gems/ruby/1.9.1/bin/unicorn_rails:23:in
    </code>'</p>
  </blockquote>
  
  <p>VDS has 1.5Gb of RAM and it's enough for unicorn:</p>
  
  <pre><code>cat /proc/meminfo
  </code></pre>
  
  <blockquote>
  <pre><code>MemTotal:        1585152 kB
  MemFree:          989580 kB
  Cached:           425296 kB
  Active:           348504 kB
  Inactive:         175356 kB
  Active(anon):      98488 kB
  Inactive(anon):       76 kB
  Active(file):     250016 kB
  Inactive(file):   175280 kB
  Unevictable:           0 kB
  Mlocked:               0 kB
  SwapTotal:        204800 kB
  SwapFree:         204800 kB
  Dirty:                12 kB
  Writeback:             0 kB
  AnonPages:         98564 kB
  Shmem:              3604 kB
  Slab:              71680 kB
  SReclaimable:      66144 kB
  SUnreclaim:         5536 kB
  </code></pre>
  </blockquote>
  
  <p>I have unicorn_rails v4.5.0</p>
  
  <p>Unicorn starts by following command:</p>
  
  <p><code>bundle exec unicorn_rails -c /var/www/staging/current/config/unicorn.rb -E production -D</code></p>
  
  <p>What i'm doing wrong here?</p>
  
  <hr>
  
  <p>Hmm, i remembered, that previously i had following strange error:</p>
  
  <pre><code>failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p327' -c 'cd /var/www/staging/current &amp;&amp; bundle exec unicorn_rails -c /var/www/staging/current/config/unicorn.rb -E production -D'" 
  </code></pre>
  
  <p>Maybe it is somehow related to memory problems…</p>