Re: SQLDataReader

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Sahil Malik (contactmethrumyblog_at_nospam.com)
Date: 11/30/04


Date: Tue, 30 Nov 2004 01:14:18 -0500

Michael,

First of all .. I'm glad a pop star of your stature is coding in .NET. ;-).

Secondly - about the dispose - you don't !!! The thing about Dispose is -
it's just as good as the class implemented it. I posted this on my blog a
while back
http://dotnetjunkies.com/WebLog/sahilmalik/archive/2004/11/12/31798.aspx

While that post is mostly about "Connection Pooling" - it does shed some
light on "Why Dispose isn't the magic bullet". (Albeit it's still good, and
you should call it when you can).

The best you can do is to wait until GC kicks in and cleans that up for you.
... while it can be argued that .NET should have given you the ability to
knock out an object if you decided to - that is what you had to do in C++ -
you had to delete for every new you did. And that lead to NOTHING BUT
PROBLEMS !!!. Garbage collector and the non deterministic model is awesome -
even though it is barely 2% shorter of the bestest possible picture - it's
still pretty damn good for no effort on your part.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"Michael Jackson" <stratojack@cox-internet.com> wrote in message
news:10qo3gehbu3e473@corp.supernews.com...
> I've read Dispose, Finalize, etc till I'm blue in the face. How to I
> implement Dispose on a SQLDataReader if it's not in a class?
>
> Michael
>
> "W.G. Ryan eMVP" <WilliamRyan@NoSpam.gmail.com> wrote in message
> news:%234cp7Eq1EHA.412@TK2MSFTNGP14.phx.gbl...
>> NonDeterminstic Finalization.
>> http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=6905
>>
>> --
>> W.G. Ryan MVP (Windows Embedded)
>>
>> TiBA Solutions
>> www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
>> "Michael Jackson" <stratojack@cox-internet.com> wrote in message
>> news:10qo18mb5pf49d8@corp.supernews.com...
>>> My application is using the SQLDataReader to retreive and itereate thru
>> rows
>>> of data from SQL Server, then for each row of that SQLDataReader,
>>> selects
>>> related rows from another table via yet another SQLDataReader. When I
>> finish
>>> with a row, I do a SQLDataReader.Close and set it to nothing, but my
>>> .NET
>>> Memory Profiler shows that the instances of the SQLDataReaders are never
>>> being disposed.
>>>
>>> Am I missing something?
>>>
>>> Thanks,
>>> Michael
>>>
>>>
>>
>>
>
>



Relevant Pages

  • Re: asp_wp.exe utilized 100% of CPU
    ... In my idea are you only spoiling time in by letting calling senseless times the dispose l. ... SqlConnection dbconn = new SqlConnection; ... SqlCommand cmd = new SqlCommand ... connection pooling, a close/dispose doesn't necessarily actually close the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Wheres my memory going?
    ... When you get there if you are still having problems and the other steps from my blog entry have not helped, please post a small reproducible sample. ... when I monitor the memory on my device and create then subsequently ... dispose of a number of my forms the memory should usage will rise and then ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: dispose()
    ... You can't dispose "connection pooling". ... - Sahil Malik ... the syntax is unload but how about aspx? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Dispose Question
    ... I had a discussion with one of the CLR devs on his blog about this and he said in effect "well mostly" ... Just a quick question on implementing the Dispose pattern. ... The .NET Framework SDK documentation states that an ObjectDisposedException ...
    (microsoft.public.dotnet.framework)
  • Re: Connection.Close or End Using or Both
    ... whenever a class implement IDisposable do use Dispose (which ... Blog: http://cs.rthand.com/blogs/blog_with_righthand/ ... Note that what connection does in Dispose might change in future. ... usually code a Try...Finally block. ...
    (microsoft.public.dotnet.framework.adonet)