DEV Community

Caleb Hearth
Caleb Hearth

Posted on • Originally published at on

Reduce Rails' Boot Memory by Removing Mail

Rail’s actionmailbox and Ruby’s mail (used by both actionmailbox and actionmailer) gems create a lot of memory bloat in applications, and they’re often not required for your app.

According to Derailed, ActionMailbox adds about 31.6 MiB to your app’s memory footprint on startup (this is bundle exec derailed:mem on Rails 7.0.8, most (~29 MiB) of which comes from mail which then adds another ~2.2 MiB when required separately.

rails/all: 58.8125 MiB action_mailbox/engine: 31.6406 MiB action_mailbox: 31.6094 MiB action_mailbox/mail_ext: 31.6094 MiB action_mailbox/mail_ext/address_equality.rb: 29.4375 MiB mail/elements/address: 29.4375 MiB mail/parsers/address_lists_parser: 29.4063 MiB mail: 2.1719 MiB (Also required by: recipient_interceptor) mail/field: 0.4844 MiB net/smtp: 0.4375 MiB mail/message: 0.4375 MiB rails: 15.1875 MiB (Also required by: active_record/railtie, active_model/railtie, and 22 others) 
Enter fullscreen mode Exit fullscreen mode

Something that’s not super well known is that Rails is really a wrapper around a...

Read More

Top comments (0)