EL Caching Block and Dispose

  • Thread starter Thread starter Chris Dunaway
  • Start date Start date
C

Chris Dunaway

If I place objects into the cached that implement an IDispose, are they
automatically disposed when removed? Looking at the code it doesn't
appear so. How can I handle this? Anyone with a suggestion?

Chris
 
In this particular case, I was caching a DataSet. The code I am
referring to is the Enterprise Library source code.
 
The Dispose method in a dataset will not dispose of any tables or rows (never
touch them). You usually dont need to worry about datasets unless they are
extremelly huge and are being marshalled somewhere. The GC is very efficient
in getting rid of instances that are deferenced from root instances.

HTH,

Erick Sgarbi
www.blog.csharpbox.com
 
My concern is not about datasets in particular. I am concerned about
caching any object that requires disposing using the Enterprise
Library. The Tnterprise Library does not seem to call Dispose when an
object that requires it is removed from the cache.
 
The Tnterprise Library does not seem to call Dispose when an object that
requires it is removed from the cache.

No need to dispose of your managed objects if they don't use unmanaged resouces.
If they "do" need to be disposed, make sure they implement the dispose pattern
by writting a finalizer... even though finalizers are expensive, you at least
will be certain that "eventually" your unmanaged resources will be freed.
Furthermore, you can always modify or bake your own caching engine.


HTH,

Erick Sgarbi
www.blog.csharpbox.com
 
Back
Top