2. Rails Panel

If you are using Google Chrome, there is a handy Chrome extension called Rails Panel. Download it from the chrome web store.

This extension will show you the breakdown of time taken in Rendering, ActiveRecord etc.

The gem 'meta_request' needs to be added to the development group in the Gemfile, for the data to appear in Rails panel.

3. Scout DevTrace

Using the scout agent (add gem 'scout_apm' in the Gemfile) in development mode will show a beautiful panel with the breakdown of time consumed in various sections - Views, Middleware, ActiveRecord, controllers etc. It also shows N+1 queries and backtraces.

You need to start the server with the environment variable SCOUT_DEV_TRACE=true for this.

Running perf:mem_over_time will boot up the app and show the memory consumed by the app, as its hit by a larger amout of requests.

USE_SERVER=puma bundle exec derailed exec perf:mem_over_time

If the memory remains constant after a point, then the app does not have any memory leaks. But if the memory keeps increasing, then there is a memory leak. You can debug further by looking at the objects in the memory