EL Caching Block and Dispose

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
 
C

Chris Dunaway

In this particular case, I was caching a DataSet. The code I am
referring to is the Enterprise Library source code.
 
N

notifications

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
 
C

Chris Dunaway

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.
 
E

Erick Sgarbi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top