Re: String to byte[] reloaded
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Mon, 12 Feb 2007 13:38:02 -0000
nano2k <adrian.rotaru@xxxxxxxxxxx> wrote:
No, they're completely different - if you get to do the allocation, you
can reuse the same buffer several times.
That's right. But in my particular case, I don't need to use the
buffer several times. I'm just forced to create an extra buffer just
to pass data to the compresion method. That's my only problem.
Unfortunately, I cannot change the compress method's signature (e.g.
to accept an MemoryStream object as input data, etc), so I thought I
will be able to adapt my code, because this is where I'm 100% in
control.
You wanted to reduce the overall memory consumption, right? So create a
buffer and reuse it, encoding different strings into the same byte
array.
Just how large are the strings you're compressing? Can you not
serialize (or pseudo-serialize) the operation so you're only
compressing a few strings at a time?
I cannot keep control on the size of the request because the request
is based on an SQL statement that could virtually return tens of megs
of data (imagine for example a report for anual activity for a
comapny). Now, because all runs inside a webservice, there can be
multiple requests of such type
If there are no bounds to the amount of data you need to compress, you
really, really should be streaming it. Grabbing into one lump is never
going to be a good option.
You *may* be able to get at the UTF-16 encoded (internal) version withI don't know what's worst. To make sure I handle very careful such a
unsafe code, but I'd strongly recommend against it.
buffer or to risc the reliability of my webservice...
It sounds to me like you should look very carefully at the overall
architecture and your compression API.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: String to byte[] reloaded
- From: nano2k
- Re: String to byte[] reloaded
- References:
- String to byte[] reloaded
- From: nano2k
- Re: String to byte[] reloaded
- From: Barry Kelly
- Re: String to byte[] reloaded
- From: nano2k
- Re: String to byte[] reloaded
- From: Jon Skeet [C# MVP]
- Re: String to byte[] reloaded
- From: nano2k
- String to byte[] reloaded
- Prev by Date: System.Transactions and database locking.
- Next by Date: Re: System.Transactions and database locking.
- Previous by thread: Re: String to byte[] reloaded
- Next by thread: Re: String to byte[] reloaded
- Index(es):
Relevant Pages
|