RE: GC Bug .net 2.0.50215 by ArthurM
ArthurM
Tue May 24 19:12:02 CDT 2005
Socket is declared within the funciton, the funciton exits, all external
references other then refernece from IOCP are gone, there is no way to get
the object out of IOCP pool without triggering send/rcvd action, if action
never comes up - hung connection. IMHO there should be a way to remove the
reference from IOCP or GC should do it by itself.
"Cowboy (Gregory A. Beamer) - MVP" wrote:
> Looking at the pseudocode alone, I do not see deferencing of the Socket. The
> read will finish, but that does not mean the socket has gone out of scope. If
> this is the type of code you are looking at, the lack of GC cleaning the
> objects is correct, as the Sockets are still active. Is there something more
> that is missing from the pseudocode?
>
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Arthur M." wrote:
>
> > Async functionality prevents an object from garbage collection.
> >
> > To reproduce:
> >
> > Create a socket
> > establish connection
> > Create NetworkStream with Ownership Of a socket (or just work socket directly)
> > Call BeginReceive on stream or socket
> > dereference network stream
> > The conneciton will stay up until parent process is terminated.
> >
> > What GC should be doing is releasing a handle of an underlying socket which
> > it does not.
> >
> > pseudo code:
> >
> > void init()
> > {
> > init socket
> > socket.connect()
> > init networkstream(owns the socket)
> > networkstream.beginread(async parameters)
> > }
> >
> > void main()
> > {
> > for (int j = 0; j < 100; j++)
> > {
> > init();
> > }
> > GC.Collecti();
> > GC.WaitForPendingFinalizers();
> > break here (console read)
> > }
> >
> > netstat will show 100 established connections that will never go away.
> >