Hello
I am getting an OutOfMemory error when I try to call close on Folder
with expunge set to true.
This is happening when I am having a large a number of e-mails with
large attachments to be expunged.
Any one else experienced this error? There are some postings that
indicate that there might be a possible leak in JavaMail API, but
nothing seems to be conclusive.
I will be using a memory profiler to try to figure out what exactly is
causing the leak, but any hints will be helpful.
Thanks
Harsh
Greg R. Broderick - 07 Apr 2006 17:44 GMT
hagarwal@tamaleresearch.com wrote in news:1144334300.712910.164650
@e56g2000cwe.googlegroups.com:
> I am getting an OutOfMemory error when I try to call close on Folder
> with expunge set to true.
Source code?
Which version of JavaMail?
Which subtype of Folder? javax.mail.Folder is an abstract class that
has at least two concrete subclasses, com.sun.mail.imap.IMAPFolder and
com.sun.mail.pop3.POP3Folder.
You might also have better success asking this question on a JavaMail-
specific forum, such as the mailing list that is run by Sun for
JavaMail. See
<http://java.sun.com/products/javamail/community/mailinglists/index.htm
l> for details. This mailing list is also gatewayed to the new group
gmane.comp.java.sun.javamail.general at the news server news.gmane.com.
Cheers
GRB
hagarwal@tamaleresearch.com - 10 Apr 2006 14:25 GMT
Allright, so its not closing the folder. It seems that Sun's
implementation of Javamail API hold messages in memory (isn't that
stupid). So my applciation was throwing Outofmemory when there were
many messages with huge attachments.
hagarwal@tamaleresearch.com - 18 Apr 2006 18:52 GMT
For anyone interested, I had to re-architect my mail processor to
dynamically figure out whether it has enough memory to process the next
message. If it does not, it closes the folder thus making all the
messages available for garbage collection.
One can argue that this is not 100% fool-proof, but I have load tested
it sufficiently to be confident that the solution will work.