Skip to main content

High memory usage on large POP3 messages.

  8 posts   Feedicon  
Replies: 7 - Last Post: December 21, 2009 23:02
by: netray
showing 1 - 8 of 8
Posted: December 15, 2009 00:07 by netray
I'm experiencing exactly the same problems as in

and I have exactly the same task: dump POP3Message contents to .eml file.

In your case, you know that the only operation you're going to do on the message is to write it to your stream. While it would certainly be possible to optimize that case, that wouldn't be the right optimization for all cases. A more generally useful optimization that I've considered is to cache the messages on disk instead of in memory. That would reduce the memory required for your case, but wouldn't be as efficient. I'm willing to consider a special optimization to handle your case, but it certainly couldn't be the default behavior.

How can I optimize memory usage for this case? Since I do not know the maximum allowed size of mime messages in the inbox - changing -Xmx option will always be a temporary solution.
Posted: December 19, 2009 06:14 by Bill Shannon
Use IMAP? Smile

With POP3 you don't really have any choices. This is on my list of things to improve...
Posted: December 19, 2009 19:15 by netray
Unfortunatelly I cannot force all customers to switch to IMAP.

Do you have a roadmap for future javamail releases? Since you have it on your list, could you give an estimated date? It doesn't have to be anything fancy - simple property would be completely sufficient.

In an environment where memory is limited (multithreaded daemon downloading and inserting new mail to DB from multiple accounts at once) dumping message contents to file and reading it with SharedFileInputStream is much safer - it doesn't have to be fast - it has to be reliable. There are customers who do not understand that there are better ways of sending 400mb files Smile.
Posted: December 20, 2009 03:08 by Bill Shannon
Ok, I threw together something that I think will work for you. Contact me at and I'll send you a version for testing.
Posted: December 20, 2009 11:55 by netray
Thank you very much!

I've sent you an email.
Posted: December 21, 2009 01:36 by Bill Shannon
I haven't gotten your email.
Posted: December 21, 2009 12:09 by netray
I have sent you another one.
Posted: December 21, 2009 23:02 by netray
Works like a charm! Thank you very much.
showing 1 - 8 of 8
Replies: 7 - Last Post: December 21, 2009 23:02
by: netray
Please Confirm