Identifying source of excessive memory usage in forked Rails 6.1 app

36 Views Asked by At

I have two Rails applications hosted on Heroku. One is the main application, the second is a fork of that application. They have exactly the same Gemfile and Gemfile.lock, and mostly the same code with some tweaks to the forked version. The forked version is using about twice the amount of RAM than the main one. Over the past several days I've looked through many articles and SO posts which resulted in making some great improvements for both applications, including setting up jemalloc through a Heroku buildpack and moving gems to more appropriate groups.

I have run derailed_benchmarks using the production environment locally (as suggested) and found one striking difference that I think points to my issue: the output of the command bundle exec derailed exec perf:mem.

(original stack)
TOP: 165.375 MiB
  application: 74.625 MiB

(forked stack)
TOP: 312.0273 MiB
  application: 74.875 MiB

The application looks like it is using about the same amount of memory (75MiB) in both stacks, while the TOP level memory load is double the memory load of the original application. This is almost exactly what I'm seeing on Heroku on boot.

I have diff'd the entire code base to make sure there are no extra requires, compared heaps between the two stacks, verified that their Bundle sizes are about the same, inspected allocated and retained objects - both applications track the same. What else can I do to find the source of this difference?

Edit - Replace image with code block

0

There are 0 best solutions below