Search code examples
c#socketsmemorymemory-leaksgarbage-collection

What is OverlappedData and how to clean a memory from this? C#


Using System.Net.Sockets I run ReceiveAsync() method and it works correctly. But when a client program shuts down, the socket leaves OverlappedData in memory. What is it and how can I remove it? Unfortunately I can't just leave it, because is it a memory leak. Could you help me, please? 15 000 000 is a size of the socket's buffer to receive messages. OverlappedData

I tried to find some solutions to solve the problem but I didn't succeed.


Solution

  • So. One of the solutions is using Receive() instead of ReceiveAsync(). It does work correctly and it doesn't create any memory leaks. But I'd still like to know if there is any way to remove OverlappedData from memory. I can't believe that there is no way to use ReceiveAsync() without creating memory leaks.

    Receive()