title: Random 500 & 404 errors - Gitlab
body: <p>I get random friendly 500 and 404 errors on my Gitlab installation. Everything works fine except that.</p>
  
  <p>It is really annoying, sometimes the pages work, sometimes I need to refresh the page a couple of times for it to display.</p>
  
  <p>Here's the errors I get in <code>/etc/httpd/logs/error_log</code></p>
  
  <pre><code>ActionView::Template::Error (cannot map `/home/git/gitlabhq/vendor/bundle/ruby/1.9.1/gems/charlock_holmes-0.6.8/ext/charlock_holmes/dst/share/misc/magic.mgc' (Cannot allocate memory)):
  1: - file = tree_full_path(content)
  2: %tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) }    3:   %td.tree-item-file-name
  4:     = tree_icon(content)
  5:     = link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true
  6:   %td.tree_time_ago.cgray
  7:     - if index == 1
  app/helpers/tree_helper.rb:4:in `tree_icon'
  app/views/refs/_tree_item.html.haml:4:in `_app_views_refs__tree_item_html_haml__359204534986361082_50783740'
  app/views/refs/_tree.html.haml:37:in `block in _app_views_refs__tree_html_haml__2791169573873392874_51939480'
  app/views/refs/_tree.html.haml:36:in `each'
  app/views/refs/_tree.html.haml:36:in `_app_views_refs__tree_html_haml__2791169573873392874_51939480'
  app/views/refs/tree.html.haml:2:in `_app_views_refs_tree_html_haml__1175555315298044292_52501320'
  app/controllers/refs_controller.rb:40:in `tree'
  
  
  ^GOut of memory (Needed 8160 bytes)
  
  ActionView::Template::Error (Mysql2::Error: MySQL client ran out of memory: SELECT COUNT(*) FROM `users` ):    25:       %h5 Users
  26:       .data.padded    27:         = link_to admin_users_path do
  28:           %h1= User.count
  29:         %hr
  30:         = link_to 'New User', new_admin_user_path, class: "btn small"
  31:  config/initializers/connection_fix.rb:22:in `execute'
   app/views/admin/dashboard/index.html.haml:28:in `block in _app_views_admin_dashboard_index_html_haml___3571568531981020694_30874020'
   app/views/admin/dashboard/index.html.haml:27:in `_app_views_admin_dashboard_index_html_haml___3571568531981020694_30874020'
  </code></pre>
  
  <p>I am new to the Ruby world.</p>
  
  <p>Additional Notes: </p>
  
  <ul>
  <li>OS: Centos 5</li>
  <li>Gitlab v2.8.2</li>
  <li>The issue almost never appears on admin pages or what not.. only on repository pages such as file tree, graphs or commits</li>
  </ul>