Why do NameValuecollections Disapear from the cache?

A

Alex

Hi


I am opening an xml file into a dataset and then converting it to a
namevaluecollection and then saving the collection in the cache for use
later. The cache dependency is set to the xml file however the collection is
cleared after about a minute even though it is not removed from the cache.
If I save the dataset on the cache it remains there indefinately. I can
resue the collection many times before it is cleared. The xml file is not
touched or changed either.

I believe the dispose method on the collection is being called but I cannot
figure out why. My only guess is that the garbage collector does not see the
cache as a strong reference and therefore assumes that the collection is to
be cleared

Can you only save things that can be persisted to file in the cache???

alex
 
G

Guest

You can persist anything in the cache. You can also controll how much time
it's staying there, its sliding expiration and so on. I don't know what
exactly is your mistake, but if you use the Cache class properly, you should
get the desired result!

Hope that helps!
Regards,
Kostadin Kostov
 
J

Joe Fallon

I agree.
Perhaps something *is* touching the XML file.
Do you have a virus scanner running?
 
A

Alex

I have tried a number of things now including a hashtable instead of the
namevaluecollection. I also tried implenting my own collection and I found
that the finalize method is called on the collection even though it is not
removed from the cache. I have removed any dependecy on the file so that
even if the file changes (which it wasn't)

What is strange is that the collection stays on the cache and when I test it
I get a valid reference back however all the items in the collection are
removed.

If I use a dataset object there is no problem

My guess seems to be the garbage collector is clearing data from the objects
on the cache however it is not removing the objects themseleves from the
cache. I have found the collection is cleared about 45 seconds after it is
added to the cache.


any help apreciated
alex
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top