I've been using your software now for a few months tracing down memory leaks and it has been invaluable.
However I have a question I'm hoping you could help me with.
I have a system that periodically (ie once a minute) does some data activity via OLEDB. I've noticed that many of my OLEDB objects are registering as being 'undisposed' even though I specifically 'close' them and assign them 'nothing'.
To try and rectify this as per one of your tutorials, I moved all the data interaction code into Using - End Using blocks.
However I still see many 'undisposed' instances. The objects most commonly undisposed are:
My question is, are undisposed instances really bad? My understanding is the object has been garbage collected (and certainly there aren't any extraneous live instances lying around), but just didn't have 'disposed' explicitly called on them.
However if I'm using the Using/End Using statement, shouldn't the disposing actions be automatically taken care of for me?
Thank you in advance for any help you might be able to provide.
You can only take care of disposing instances that you create yourself. Instances created by the framework must be destroyed by the framework. So if you have undisposed instances that are created by the framework and that are not correctly disposed, there's not much you can do. However, even though failing to dispose instance can cause big memory usage problems, in many cases an undisposed instance does not affect performance and memory utilization.
System.Data.RBTree<K>.RBTreeEnumerator: Only contains an empty Dispose method. The Dispose method exists since IEnumerator<T> derives from IDisposable
System.Data.OleDB.SessionWrapper and System.Data.OleDB DataSourceWrapper: Derives from SafeHandle and it is highly recommended that instances of these classes are disposed. Do you have any information about who's creating these instances?
System.ComponentModel.EventHanderList: Only clears the head of a list of delegates. There should be no reason for disposing an EventHandlerList instance, as long as the list itself becomes eligible for GC.
SciTech Software AB
I noticed the same thing was happening with my program. The DataSourceWrapper would increase its undisposed counter and I do not know how to correctly dispose of it. How is this done?
Your previous answer says that it is highly recommended that they are disposed of.
I did notice that if you create a OleDb.OleDbDataAdapter with a closed connection then the connection is opened a closed for you automatically. This process left a DataSourceWrapper undisposed. If I first opened the connection myself, then a DataSourceWrapper was not created.
As mentioned, failing to properly dispose instances can cause bad memory and resource utilization, but it often will not create a memory leak. Unless the dispose method is used to remove references to the instance (e.g. an event handler), the memory/resource will be reclaimed eventually.
SciTech Software AB
Users browsing this forum: No registered users and 11 guests