Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion


For appeals, questions and feedback, please email

Multiple IMAPFolder objects are present in heap memory and resulting in heap space error

user-t5f40May 4 2023

Hi Team,

I have a query, i'm reading emails from gmail and storing the content of that in my database.
so as part of this i can see that multiple IMAPFolder objects are present and occupying most of the heap space and resulting in out of memory error.

The objects are not being garbage collected.

can see that messageCache is having the size of the number of emails present in gmail.
Could you please suggest here on how we can make sure IMAPFolder objects are cleared?

Post Details
Added on May 4 2023