Re: 'Set Object = Nothing'... do you still do this in VB.net????
- From: "Stephany Young" <noone@localhost>
- Date: Tue, 23 Oct 2007 01:03:43 +1300
I said that WebRequest was off the top of my head.
It was actuallly WebResponse as Jon pointed out.
The documentation for the WebResponse.Close method explicity states (in the remarks) that the instance must be closed to avoid running out of system resources.
That's the only one I have encountered however I would find it difficult to accept that, among the thousand's of classes in the Framework, there are not other classes with a similar note.
One thing I am not going to do is go and find them for the sake of it.
"Andrew Morton" <akm@xxxxxxxxxxxxxxxxxxxxxx> wrote in message news:eTe3ldJFIHA.5328@xxxxxxxxxxxxxxxxxxxxxxx
Jon Skeet [C# MVP] wrote:Andrew Morton <akm@xxxxxxxxxxxxxxxxxxxxxx> wrote:Stephany Young wrote:There are some classes in the Framework where you MUST 'destroy' an
instance of it yourself. Off the top of my head, the WebRequest
class is one.
Assuming that is correct for the WebRequest class, how do you tell?
There is nothing I can see in the docs (framework 1.1) to say that
must be done, whereas, for example, System.Drawing.Bitmap has a
Dispose() method, although I suppose you have to infer from the
existence of a Dispose() method that it needs to be called.
You need to know that the class implements IDisposable. WebRequest was
an unfortunate example, as unfortunately it *doesn't* require
disposal, not implementing IDisposable.
Phew! I was getting worried there - I thought maybe there were classes that need to be disposed of yet no documentation saying so!
WebReponse, however, is a reasonable example.
Hmmm... in that particular case, doesn't WebResponse.Close take complete care of making it available for GC once it's gone out of scope? I see that WebResponse implements IDisposable but has no Dispose() method, and I haven't seen a memory leak in my ASP.NET application.
Andrew
.
- Follow-Ups:
- Re: 'Set Object = Nothing'... do you still do this in VB.net????
- From: Andrew Morton
- Re: 'Set Object = Nothing'... do you still do this in VB.net????
- References:
- 'Set Object = Nothing'... do you still do this in VB.net????
- From: Alan Mailer
- Re: 'Set Object = Nothing'... do you still do this in VB.net????
- From: Stephany Young
- Re: 'Set Object = Nothing'... do you still do this in VB.net????
- From: Andrew Morton
- Re: 'Set Object = Nothing'... do you still do this in VB.net????
- From: Jon Skeet [C# MVP]
- Re: 'Set Object = Nothing'... do you still do this in VB.net????
- From: Andrew Morton
- 'Set Object = Nothing'... do you still do this in VB.net????
- Prev by Date: RE: Error dealing with '%STUDIO_LIB_VC80%
- Next by Date: Vista and SQL server 2005 problem
- Previous by thread: Re: 'Set Object = Nothing'... do you still do this in VB.net????
- Next by thread: Re: 'Set Object = Nothing'... do you still do this in VB.net????
- Index(es):
Relevant Pages
|