Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Mail Parsers takes a lot of memory #165

Open
schneems opened this issue Sep 17, 2020 · 2 comments
Open

Loading Mail Parsers takes a lot of memory #165

schneems opened this issue Sep 17, 2020 · 2 comments

Comments

@schneems
Copy link

schneems commented Sep 17, 2020

See this line:

@address = Mail::Address.new(address)

If you run this script you'll see that loading parsers from the Mail gem requires a LOT of memory:

require 'mail'
require 'get_process_mem'

before = GetProcessMem.new.mb
address = Mail::Address.new("developer@example.com")
address.domain
after = GetProcessMem.new.mb

puts "Enabling email parsing requires #{after - before} mb of memory"
# => Enabling email parsing requires 30.9296875 mb of memory

Just throught you should know. Also since the call usually happens at run time instead of load time it's 30mb of memory use for every process.

Here's a discussion on the issue and a proposed (but not accepted) alternative

@dogweather
Copy link

Suggestion: somehow enable the user to choose whether to optimize for speed (current version) or memory (proposed change). That is, instead of trying to please everyone or making these optimization decisions ahead of time. :-)

My use case: A Rails app which only occasionally sends email and never receives it. But every instance pays the 30+ MB price, making it difficult to run efficiently on a PaaS, Heroku.

@micke
Copy link
Owner

micke commented Feb 7, 2021

Hi, sorry for not attending to this earlier!

I like the idea, and would prefer the default behaviour to use the mail gem.
I currently have no spare time to put into this feature, but i would gladly accept a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants