Have you looked at PowerCollections ? It has a BigList<T> class which I think 
would solve your problem of resizing.
 
Basically, it is a balanced tree of small arrays (length is 256 in release mode 
i think). We use it here and it is really fast. The big plus of that collection 
is that insertion and removal are much less expensive and the size will not 
double each time the list needs to grow.
 
Have a nice day,
 
Sébastien

 
-----Original Message----- 
From: dave wanta [mailto:[EMAIL PROTECTED] 
Sent: Thu 2006-07-06 8:19 PM 
To: 
Cc: 
Subject: Re: trim byte array



Well, it's relatively simple. All I need to-do, is return the byte array of
read data.

internal byte[] GetData( int index, byte[] terminatingData ){

MemoryStream ms = new MemoryStream();
while( !eof ){
countRead = ReadSocket(data, 0, data.Length);

//store byte array
ms.Write( data, 0, countRead );

if( countRead  > terminatingData.Length )
    eof = CheckForEndOfFile( data, countRead, terminatingData );
else
    eof = CheckForEndOfFile( ms, terminatingData );
}

}

return ms.ToArray();
}

This is very rough pseudo code. It's what the original method was doing.
I'm trying to decrease the memory footprint.

Once again, thanks all for your feedback.

Cheers!
Dave

----- Original Message -----
From: "Stoyan Damov" <[EMAIL PROTECTED]>
To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM>
Sent: Thursday, July 06, 2006 4:13 PM
Subject: Re: [ADVANCED-DOTNET] trim byte array


> Dave,
>
> Are you willing to share with us the interface(s) of your component.
> If we see how your component's clients will use it, we might be able
> to come up with an idea.
>
> Cheers,
> Stoyan
>
> On 7/6/06, dave wanta <[EMAIL PROTECTED]> wrote:
> > I wish I could. But basically these are large blobs (usually GIS images,
but
> > can be regular images and sometimes large zips).
> >
> > Unfortunately I don't have control over the project, and only have this
> > little box I can work in (read data from a socket, and optimize the
> > memory ).
> >
> > I was using a MemoryStream, simply because it was quick and easy. I'm
moving
> > to a dynamically expanding byte array, but the Trimming part is what I
> > was/am worried about.
> >
> > Cheers!
> > Dave
>
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to