title: Do I need to build Ruby with jemalloc and use the gem if I'm using a Heroku buildpack?
body: <p>Sample a <strong>Ruby (2.4.1)</strong> on <strong>Rails (4.2.8)</strong> app, configured with Puma and deployed on <strong>Heroku (cedar-16)</strong>. Currently developing on a <strong>Mojave 10.14.5</strong> MBP. I'm on a mission to cut down memory usage and recently discovered jemalloc <a href="https://medium.com/rubyinside/how-we-halved-our-memory-consumption-in-rails-with-jemalloc-86afa4e54aa3" rel="nofollow noreferrer">via this post</a>. I reinstalled Ruby (using RVM) with jemalloc enabled as proved by the following output - <code>-lpthread -ljemalloc -lgmp -ldl -lobjc</code>. I proceeded to add the <a href="https://rubygems.org/gems/jemalloc/versions/1.0.1" rel="nofollow noreferrer">jemalloc gem</a> and bundle installed without a problem. I've also set up the <a href="https://elements.heroku.com/buildpacks/gaffneyc/heroku-buildpack-jemalloc" rel="nofollow noreferrer">Heroku buildpack</a> and configured necessary environment variables. </p>
  
  <p>However, with the gem in my Gemfile, I'm unable to run any rake/rails commands - <code>rails c</code> returns the following error, promptly followed by my Mac's fans firing up: </p>
  
  <p><code>ruby(45487,0x10739c5c0) malloc: *** malloc_zone_unregister() failed for 0x7fff94a3f000</code></p>
  
  <p><code>foreman start</code> gets stuck at <code>* Preloading application</code>. All issues vanish &amp; app works fine if I remove the gem.</p>
  
  <p>Since I'm not privy to how Heroku buildpacks work and how that specific one is programmed exactly, my questions are as follows: </p>
  
  <ol>
  <li>With the buildpack added, do I really need the gem installed in my project? </li>
  <li>With the buildpack added, do I need a Ruby version compiled using jemalloc?</li>
  <li>If I do need the gem, how do I get rid of the aforementioned error? </li>
  </ol>