David Erickson
2005-09-01 18:43:05 UTC
I sent this off to the dev team but I'm wondering if anyone else has noticed
this behavior, and if so has anyone done anything about it?
I have noticed a 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.
Additionally I just noticed that javamail 1.3.2 source has been released, is
it legal to fix the above problem in the source, rebuild it, and use it in
your app? It didn't look like it according to the research liscense... but
if it's a problem with the code...
Thanks,
David Erickson
===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
this behavior, and if so has anyone done anything about it?
I have noticed a 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.
Additionally I just noticed that javamail 1.3.2 source has been released, is
it legal to fix the above problem in the source, rebuild it, and use it in
your app? It didn't look like it according to the research liscense... but
if it's a problem with the code...
Thanks,
David Erickson
===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".