Jun Dalisay
Jun Dalisay

Reputation: 1275

Rails 6: How to disable Action Mailbox and Action Text from loading into Memory?

I want a new Rails 6 app without Action Mailbox or Action Text, so I create one with

rails new myapp --skip-action-mailbox --skip-action-text

I then remove them in application.rb

But when I run bundle exec derailed bundle:mem it shows that they are still there:

rails/all: 36.2539 MiB
    action_mailbox/engine: 13.5313 MiB

How can I remove them to save on memory?

Upvotes: 9

Views: 1680

Answers (2)

Thilo
Thilo

Reputation: 17735

Ran into the same issue, which actually is somewhat of a red herring. It's the derailed_benchmark gem itself that loads all of rails. See this issue:

https://github.com/rails/rails/issues/41361

I think that's because rails/all is required when running derailed bundle:mem here.

The (as yet unreleased) main branch of the gem provides the environment variable DERAILED_SKIP_RAILS_REQUIRES, but that just caused exceptions when run on my particular rails app with derailed bundle:mem.

So the solution is to either ignore this and take into account that action_mailbox is not in fact loaded by your app, or use dynamic benchmarking as described in the README:

bundle exec derailed perf:mem

Upvotes: 0

netwire
netwire

Reputation: 7225

I have the same problem, even with my application.rb looking like this:

%w(
  action_controller/railtie
  action_view/railtie
  active_job/railtie
  sprockets/railtie
).each do |railtie|
  begin
    require railtie
  rescue LoadError
  end
end

bundle exec derailed bundle:mem still shows this:

TOP: 121.7656 MiB
  rails/all: 71.375 MiB
    action_mailbox/engine: 41.5 MiB
      action_mailbox: 41.4688 MiB
        action_mailbox/mail_ext: 41.4688 MiB
          action_mailbox/mail_ext/address_equality.rb: 39.6875 MiB
            mail/elements/address: 39.6875 MiB
              mail/parsers/address_lists_parser: 39.6094 MiB (Also required by: mail/parsers)
                mail/parsers: 7.5313 MiB
                  mail/parsers/received_parser: 5.1563 MiB
                  mail/parsers/envelope_from_parser: 1.4844 MiB
                  mail/parsers/message_ids_parser: 0.3281 MiB
          mail: 1.7344 MiB
            mail/field: 0.7813 MiB

Upvotes: 2

Related Questions