This content has been marked as final. Show 2 replies
Since 2 gigs is a array limit size the limit would seem apparent to me.
Solutions would be break it into pieces, find a different decoder or figure out if the decoder you are using will deal with files (streams).
Thanks for your response jcshell.
What/How exactly do you mean break it into pieces? I came across another reading that stated the below but not clear on how to implement it.
".....major problem with using the MimeMessage(Session, InputStream) constructor. When you use this over 2x the size of the actual message worth of memory will be allocated which can be a major problem if you have large attachment sizes. The reason this is happening is down in the ASCIIUtility.getBytes(InputStream) method. What happens is it reads the inputstream fully into a ByteArrayOutputStream, which is fine. The problem then comes is that when you call .getBytes() on that output stream it creates a copy of the byte, instead of just returning the internal byte, thus it is allocating 2x the memory. To fix this you have two options, create your own OutputStream and give access to its internal byte, or you could subclass ByteArrayOutputStream and add an accessor to the buf byte array since its protected, and return that..."