EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElMessagePart does not Clone DataStream

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#22474
Posted: 11/14/2012 01:46:39
by Eugene Mayevski (EldoS Corp.)

Quote
Niklas Kjellander wrote:
The scenario is quite simple. I want to add a file as an attachment to a mail message and serialize the message to disk. Maybe this was not really what you wanted me to describe (I'm not sure what you mean by "in regards to MIME")?


Thank you, that's it. Though I don't exactly understand what you plan to do with the message later (cause as said such message can hardly be sent anywhere).

Quote
Niklas Kjellander wrote:
By the way, are you going to clone the DataStream property or not when cloning a message part? I feel that this thread kind of lost it focus on the initial topic.


Definitely not. Cloning a DataStream causes unwanted consumption of resources, and copying the reference to original causes troubles later. So it's up to you how to deal with this.


Sincerely yours
Eugene Mayevski
#22475
Posted: 11/14/2012 02:30:22
by Niklas Kjellander (Standard support level)
Joined: 09/30/2008
Posts: 49

We have customers that send mails with large attachments. In our product the user composes messages in a "scripting environment" and therefore I cannot give you a strait answer what is to be done with the message later on, it's all up to the user of our product.

I see your point on the cloning part, and I will try to deal with it.
#22480
Posted: 11/14/2012 06:28:56
by Niklas Kjellander (Standard support level)
Joined: 09/30/2008
Posts: 49

Also, I've noticed that AssembleMessage seems to make the process allocate a lot of memory. For example if the message contains an attachment where the DataStream property of the attachment part is a FileStream, the call to AssembleMessage makes the process allocate additional memory that equals to three times the size of the attachment.
#22482
Posted: 11/14/2012 07:12:51
by Eugene Mayevski (EldoS Corp.)

Yes, it does, and this is where your code crashes (due to out of memory error) when you attach 170 Mb large file. We will optimize this part, though it's not that simple -- when you attach the file, MIME assembler must encode it to base64 and convert to destination charset. So temporary streams must be allocated one way or another. We will probably need to extend the assembler with OnTemporaryStreamNeeded event so that you could allocate a stream on the disk.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 1469 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!