violetbeach opened a new pull request, #159:
URL: https://github.com/apache/commons-email/pull/159
### Issue
Hello,
OOM occurred in the mail service developed using Apache-commons-email.
I debugged and found that the mail lookup function was wasting memory!
### Problem
Below is a test for reproducing the problem.
```java
@Test
void memoryTest() throws Exception {
InputStream is = new SharedFileInputStream("/test/oom.eml");
Session session = Session.getInstance(System.getProperties());
MimeMessage mimeMessage = new MimeMessage(session, is);
MimeMessageParser parser = new MimeMessageParser(mimeMessage).parse();
}
```
Below is the memory usage.

I expected to write attachments to the buffer of the output stream when
absolutely necessary.
However, it is becoming a problem by putting all bytes[] in memory.


### Sugest
So i modified these processes to use AttachmentDataSource.
Attachment DataSource uses InputStream from original DataSource to ensure
memory is not wasted.
As a result, i can get a big effect in memory usage.

> I worked hard to fix it. Feel free to let me know if you have any advice
or lack!
If you need the tested eml file, I will send it to you by email.
Thanks very much. 🙇
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]