C
C#2y ago
.dark4

❔ Memory leak leading to overflow crash if server doesn't gracefully close socket with my client app

if my client app has a socket open with server, and server stops working/closes my client app gets a runaway memory leak that causes overflow. Typically when the server closes the socket what happens to the client? Should I poll the socket connection to make sure it's open and if closed, stop the socket thread (background = true)? Trying to figure out how to go abut fixing the memory leak. this is how I open the socket in my winform client
Thread tcpSocketThread = new Thread(api.ConnectToGSP);
tcpSocketThread.IsBackground = true;
tcpSocketThread.Start();
Thread tcpSocketThread = new Thread(api.ConnectToGSP);
tcpSocketThread.IsBackground = true;
tcpSocketThread.Start();
8 Replies
.dark4
.dark4OP2y ago
These are my socket connect and disconnect methods https://pastebin.com/p5QK2fx1
Pastebin
public void ConnectToGSP() { IPAddress iPAddress = IPAdd...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Buddy
Buddy2y ago
Take a snapshot in diagnostics
.dark4
.dark4OP2y ago
.dark4
.dark4OP2y ago
.dark4
.dark4OP2y ago
.dark4
.dark4OP2y ago
it's caused by the receive method
Buddy
Buddy2y ago
Call BeginReceive in the callback of BeginRecieve. And skip the while loop. https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.beginreceive read example. As BeginReceive is not blocking. If you want blocking, use Recieve
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server