Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

GC Bug .net 2.0.50215

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arthur M. - 11 May 2005 16:20 GMT
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.
Cowboy (Gregory A. Beamer) - MVP - 12 May 2005 14:06 GMT
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!
***************************

> Async functionality prevents an object from garbage collection.
>
[quoted text clipped - 32 lines]
>
> netstat will show 100 established connections that will never go away.
Arthur M. - 25 May 2005 01:12 GMT
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.

> 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
[quoted text clipped - 47 lines]
> >
> > netstat will show 100 established connections that will never go away.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.