RE: GC and active sockets, and Pinned Memory
- From: Rob White <RobWhite@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 May 2005 08:30:17 -0700
Couldn't you just make sure that you included a distructor ~ClassName() into
your object that closes the socket on it's destruction?
"Arthur M." wrote:
> Bleh... I think I found the answer as to why, no solution as of yet though....
>
> When Socket.BeginReceive is called, buffer memory appears to be pinned,
> therefore it will never unpin it until some data shows and the call
> continues, the problem is that Socket.BeginReceive will call itself in the
> end of its call hence new buffer will get pinned, so unless GC tries to
> collect it at the moment when the call is completed but new one has not been
> initiated yet .... we have a hanging socket
>
> Anyone has any idea if there is a way to get reference count to an instance
> of a class from .NET?
>
>
>
> "Arthur M." wrote:
>
> > I'm using .net 2.0 beta2 and noticing some strange behaviour around socket
> > garbage collection.
> >
> > Problem:
> > If a socket is a part of a class which has been instantiated, socket
> > connected, and class de-referenced Socket will stay connected forever.
> >
> > Environment:
> > Sockets are doing async read/write
> >
> > Question:
> > How do i get it solved :) also - is putting something on IOCP thread will
> > cause garbage collection to fail because of internal blocking that is going
> > on. How can i clean up connected socket which is a member of a class which
> > suddenly lost refernece. Under normal conditions I do clean up, however,
> > there are scenarios where abnormal termination of a thread can cause socket's
> > parent class loose reference.
> >
> >
.
- Follow-Ups:
- RE: GC and active sockets, and Pinned Memory
- From: Arthur M.
- RE: GC and active sockets, and Pinned Memory
- References:
- GC and active sockets
- From: Arthur M.
- RE: GC and active sockets, and Pinned Memory
- From: Arthur M.
- GC and active sockets
- Prev by Date: Using assemlby without depending on it
- Next by Date: RE: Using assemlby without depending on it
- Previous by thread: RE: GC and active sockets, and Pinned Memory
- Next by thread: RE: GC and active sockets, and Pinned Memory
- Index(es):
Relevant Pages
|