Re: Memory leak with socket BeginReceive?
- From: ianrae88@xxxxxxxxx
- Date: 9 Dec 2005 08:51:01 -0800
Update. This leak is a byproduct of two things. First, all allocation
in the CLR takes place at the top of the heap. Second, the GC can't
compact memory below the highest (newest) pinned object. Every call to
socket.BeginReceive pins the buffer object that you pass in. It remain
pinned for a long time (until the data arrives on the socket), followed
by a brief instant between EndReceive and the next BeginReceive when
it's unpinned, and you process received data. Only if a GC occurs
during the brief instant, AND it's on the highest pinned buffer, will
memory be compacted. That's why a Thread.Sleep helps.
The real fix is to allocate a fixed pool of buffers early during
program startup. They're pinned but low in memory. Or use .Net 2.0
which is supposed to fix this problem :)
.
- References:
- Memory leak with socket BeginReceive?
- From: ianrae88
- Re: Memory leak with socket BeginReceive?
- From: Vadym Stetsyak
- Re: Memory leak with socket BeginReceive?
- From: ianrae88
- Memory leak with socket BeginReceive?
- Prev by Date: Re: analyse <configSections> section in app.exe.config
- Next by Date: Deserialization, SerializationBinder and Insufficient State
- Previous by thread: Re: Memory leak with socket BeginReceive?
- Next by thread: Background Update of GAC Assemblies
- Index(es):
Relevant Pages
|