violetbeach opened a new pull request, #157:
URL: https://github.com/apache/commons-email/pull/157

   ## SharedInputStream
   
   `Java Mail API` provides a mechanism to save memory usage.
   
   
![img_4](https://github.com/apache/commons-email/assets/63458653/3cd8c890-156f-4fbe-acee-d7047852d004)
   
   If you use `SharedByteInputStream`, you can use it as a **Call by 
Reference** without assigning a new byte[] of the factor.
   
   ### Before
   
   Memory snapshot for the test below.
   
   ```java
   @Test
   void memoryTest() throws Exception {
        FileInputStream fileInputStream = new FileInputStream("/test/oom.eml");
        byte[] bytes = fileInputStream.readAllBytes();
        Session session = Session.getInstance(System.getProperties());
        MimeMessage mimeMessage = new MimeMessage(session, new 
ByteArrayInputStream(bytes));
   }
   ```
   
   
![img_1](https://github.com/apache/commons-email/assets/63458653/bb9b2cdc-e8a1-4ce1-97ff-7e42871d40a5)
   
   ### After
   
   Memory snapshot for the test below.
   
   ```java
   @Test
   void memoryTest() throws Exception {
        FileInputStream fileInputStream = new FileInputStream("/test/oom.eml");
        byte[] bytes = fileInputStream.readAllBytes();
        Session session = Session.getInstance(System.getProperties());
        MimeMessage mimeMessage = new MimeMessage(session, new 
SharedByteArrayInputStream(bytes));
   }
   ```
   
   
![img_3](https://github.com/apache/commons-email/assets/63458653/538df9e5-a0b9-4a14-a6b2-029e36e14518)
   
   Thanks.


-- 
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]

Reply via email to