Re: Buffer Pooling?
From: David Browne (meat_at_hotmail.com)
Date: 05/05/04
- Next message: anonymous_at_discussions.microsoft.com: "Re: Buffer Pooling?"
- Previous message: MIke: "Buffer Pooling?"
- In reply to: MIke: "Buffer Pooling?"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Buffer Pooling?"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Buffer Pooling?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 5 May 2004 10:03:10 -0500
"MIke" <anonymous@discussions.microsoft.com> wrote in message
news:882b01c432a3$724c2f30$a401280a@phx.gbl...
> Hi, I'm writing a server that is using asynchronous IO. I
> need this server to be scalable and fast. But how do I
> implement the send and recieve buffers in an efficient
> way?
>
> If I just allocate the memory on the fly, there's no way
> to explicitly free it up, so all of these large buffers
> will be floating around until the GC runs. This might be
> okay for 100 or so connections, but 1000? I don't think
> it would.
>
. . .
>
> ARGH! Where is .NET when you need it! What are your
> thoughts?
>
Use per-thread buffers, and do it the easy way with the ThreadStatic
attribute.
in C#
[ThreadStatic()]
private static byte[] buf;
private static byte[] getBuf()
{
if (buf == null)
{
buf = new byte[1024*10];
}
return buf;
}
will allocate a seperate 10k buffer for each thread.
David
- Next message: anonymous_at_discussions.microsoft.com: "Re: Buffer Pooling?"
- Previous message: MIke: "Buffer Pooling?"
- In reply to: MIke: "Buffer Pooling?"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Buffer Pooling?"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Buffer Pooling?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|