Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 151909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:31:44+00:00 2026-05-11T09:31:44+00:00

I have a .NET2.0 C# web-app. It has a variable number of large, init-expensive

  • 0

I have a .NET2.0 C# web-app. It has a variable number of large, init-expensive objects which are shared across multiple requests but not sessioned to any given user. I therefore need to persist them in a lookup structure. These objects need to be created as required and are not required for the lifespan of the app, merely the lifespan of their usage.

Plus a bit.

The memory leaking way to do this is a simple dictionary, the memory safe way to do this is a weakreference backed dictionary, but the problem I’m having is that the GC is just too damned fast. Realistically this may not be a problem because the traffic to the objects should be such that they’ll stay alive without being forced to regenerate too much, but ideally I’d like them to scale down too.

Is there some kind of middle-ground solution I’m not thinking of which will keep the objects safely hidden from the GC for a period of time X, but also allow them to be collected at the end of that time, preferably where that time counter gets reset every time they’re used in a way similar to session tokens?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:31:45+00:00Added an answer on May 11, 2026 at 9:31 am

    I’m not sure why the HttpRuntime cache would not work here. Items inserted into the cache will be ‘renewed’ every time they are touched, thus keeping them alive until they are no longer needed; and after that they will continue to stay in cache until they expire (sliding or rolling time) or they are forced out due to memory pressure. They can also be forced out at an explicitly-set, absolute time regardless of usage:

    • Absolute time: items are forced out after the system clock passes a certain DateTime

    • Sliding (rolling) time: every time an item is touched, its countdown to death is reset. The duration of the countdown is the sliding time (for example, 5 minutes).

    Example usage:

    //adds itemObject to cache under name 'UniqueItemKey' //set to expire 5 minutes after last touched HttpRuntime.Cache.Add('UniqueItemKey',                        itemObject,                        null,                       Cache.NoAbsoluteExpiration,                       new TimeSpan(0, 5, 0),                       CacheItemPriority.Normal,                       null); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET 2.0 web app and part of the structure still has
I have a asp.net 2.0 web app which calls a long running stored proc
I have a web app built against asp.net 2.0, but keep getting the following
need ask you about some help. I have web app running in Net 2.0.
I have created a Web Application in asp.net 2.0. which is working fine on
We currently have a .NET 2.0 web app that uses forms authentication via cookies.
I have inherited a conventional three tier web app with ASP.net 2.0 for the
I have a web app where I am calling a SELECT DISTINCT query on
I have a asp.net 2.0 web site with numerous asp:DropDownList controls. The DropDownList control
I have an ASP.Net 2.0 web site, using the DotNetNuke framework (4.09), and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.