I've noticed others have had this same problem, but no answers appear to be
surfacing. So here I go again.
Using asynchronous callbacks: I am receiving incoming socket connections,
receiving the network stream, and closing the socket.
Problem is that each socket connection adds 4k of memory usage that never
clears away. I close the socket and null out my StateObject to allow for
garbage collection. So why aren't the resources being released? Is the
origional socket connection not being closed when the
StateObject.Socket.Close() is called?
Thanks again,
Jim
Eric Cadwell - 25 Feb 2004 16:38 GMT
Are you closing the NetworkStream object? Once you call GetStream the
socket is owned by the stream.
-Eric
Jim P. - 25 Feb 2004 17:45 GMT
Yup, I'm closeing the NetworkStream. This is probubly overkill, but here is
the Closing code.
// Close networkStream & Socket and NULL out resources
SocketObject.networkStream.Close();
SocketObject.socket.Shutdown(SocketShutdown.Receive);
SocketObject.socket.Close();
SocketObject.networkStream = null;
SocketObject.socket = null;
SocketObject = null;
> Are you closing the NetworkStream object? Once you call GetStream the
> socket is owned by the stream.
>
> -Eric
DotNetJunkies User - 27 Jul 2004 19:18 GMT
Jim,
I habe the same problem with a 4k memory leak each time I siphon a request off of the Listener queue using Socket.Accept. I'm shutting down and closing the socket, but with the same results.
Did you find resolution on this?
-Anthony
Anthony Iasso
Oberon Associates
---