views:

323

answers:

2

What are the options for recycling the ASP.Net application state object? I'm using that object to store queues of database connections for a web serviced based data access layer. I'm concerned that over days/weeks/months I'll end up allocating growing sums of memory on connections to db's that are no longer in use. The connections are generated automatically as needed so preserving them is not a hugely important.

It would be cool to selectively parse through the application state and drop just what I don't need. But on a practical basis simply dropping the entire object and starting fresh would work just as well. However, I need to be careful that the purge process won't kill connections currently in use.

+1  A: 

What happened before you started caching the connections? Did caching them cause any measurable improvement in performance or resource utilization? I'd be a bit surprised if it did, considering that ADO.NET does connection pooling for you.

There are no recycling options for Application state. It is per-server, per-AppDomain.

For another caching option, consider the use of the Cache object. It is also per-application, but you can set the Cache entries to expire after a period of time.

John Saunders
A: 

I did some testing and it appears the application object does reside in the app pool. (Recycling the application pool cleared out the data in the application object.)

Jeff