title: Ruby Memory Usage increases until docker container needs restarted
body: <p>I have a ruby on rails application running inside a docker container. The application runs correctly but we have noticed ruby continues to increase it's memory usage until the application stops responding and we need to restart the container. Looking for any suggestions on how to address this issue.</p>
  <p>Gemfile</p>
  <pre><code>source 'https://rubygems.org'   
  
  # Rails Dependencies
  # =====================================================
  gem 'rails', '~&gt; 5.2.6'
  gem 'bundler'
  gem 'rake', '~&gt; 12.3'
  gem 'puma', '~&gt; 4.3' 
  gem 'mysql2', '&gt;= 0.4.4', '&lt; 0.6.0'
  gem 'sass-rails', '~&gt; 5.0'
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.2'
  gem 'jquery-rails'
  gem 'jbuilder', '~&gt; 2.5'
  gem 'sdoc', '~&gt; 0.4.0', group: :doc
  
  gem 'bootsnap', '&gt;= 1.1.0', require: false
  
  # OAI-PMH 
  # =====================================================
  gem 'blacklight_oai_provider'
  
  # Automatic Import
  # =====================================================
  gem 'whenever', require: false
  
  # Hydra Dependencies
  # =====================================================
  gem 'active-fedora'
  gem 'active-triples'
  gem 'blacklight'
  
  gem 'hydra-head'
  gem 'ldp'
  gem 'nokogiri'
  gem 'solrizer'
  
  gem 'rsolr'
  gem 'devise'
  gem 'devise-guests', '~&gt; 0.5'
  
  gem 'rdf', '&lt;= 3.1.13'
  
  # Capistrano
  # =====================================================
  # gem 'capistrano-rails'
  
  # DEVELOPMENT AND TESTS ONLY
  # ===================================================== 
  group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug'
    gem 'rspec-rails'
    gem 'jettywrapper'
    gem 'listen'
    gem 'fcrepo_wrapper', '~&gt; 0.4'
    gem 'solr_wrapper', '~&gt; 2.0'
  end
  
  group :test do
    gem 'factory_bot_rails'
  end
  
  group :development do
    gem 'web-console', '~&gt; 2.0'
    gem 'spring'
  end
  </code></pre>
  <p>dockerfile</p>
  <pre><code>FROM ruby:2.7.2
  
  ENV BUNDLER_VERSION=2.2.27
  ENV RAILS_VERSION=5.2.6
  
  RUN mkdir -p /home/hydra
  WORKDIR /home/hydra
  ADD ./hydra /home/hydra
  
  RUN apt-get update &amp;&amp; apt-get -y install cron
  
  # Use JEMALLOC instead
  # JEMalloc is a faster garbage collection for Ruby.
  # -------------------------------------------------------------------------------------------------
  RUN apt-get install -y libjemalloc2 libjemalloc-dev
  ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so
  
  RUN \
    gem update --system --quiet &amp;&amp; \
    gem install bundler -v ${BUNDLER_VERSION} &amp;&amp; \
    gem install rails -v ${RAILS_VERSION} &amp;&amp; \
    bundle install --jobs=4 --retry=3
  
  # Node.js
  RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
  &amp;&amp; apt-get install -y nodejs
  
  ADD ./startup.sh /usr/bin/
  RUN chmod -v +x /usr/bin/startup.sh
  ENTRYPOINT [&quot;/usr/bin/startup.sh&quot;]
  </code></pre>