JavaMail API Closing folder causes OutOfMemory

H

hagarwal

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
 
G

Greg R. Broderick

(e-mail address removed) wrote in @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
 
H

hagarwal

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.
 
H

hagarwal

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top