3

I have a C# service which is not an ASP.NET application, but uses a singleton instance of of class HttpRuntime to cache items in its cache member. The singleton is created like this:

static private System.Web.HttpRuntime _httpRuntime = new HttpRuntime();

I want to set its maximum memory usage so I have the following in the app's config file service.exe.config:

<configuration>
 <caching>
    <cache privateBytesLimit= "50000000"   privateBytesPollTime = "00:01:00"/>
 </caching>
</configuration>

This doesn't seem to have any effect. Instead of setting it to 50MB, when I look in HttpRuntime.Cache.EffectivePrivateBytesLimit it is 720 MB.

What am I doing wrong?

1
  • 2
    HttpRuntime.Cache is static, so what do you gain by creating a new HttpRuntime instance? Commented Jun 7, 2011 at 7:40

1 Answer 1

4

You are not using the correct cache element. According to the documentation the EffectivePrivateBytesLimit property can be set with the privateBytesLimit attribute of the cache Element for caching (ASP.NET Settings Schema) element in the application's configuration file;

<configuration>
  <system.web>
    <caching>
      <cache privateBytesLimit="10000000" privateBytesPollTime="00:01:00" />
    </caching>
  </system.web>
</configuration>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.