0

On my host company, i have 2, more or less identical, .net applications. This two applications use the same pool, which has a max memory on 300 mb.

I can refresh the startpage for one of the application about 10 times, then i get a out of memory exception and the pool is crashed.

In my application i print out this memory values:
PrivateMemorySize64: 197 804.00 kb (193.00 mb)
PeakPagedMemorySize64: 247 220.00 kb (241.00 mb)
VirtualMemorySize64: 27 327 128.00 kb (26 686.00 mb)
PagedMemorySize64: 197 804.00 kb (193.00 mb)
PagedSystemMemorySize64: 415.00 kb (0.00 mb)
PeakWorkingSet64: 109 196.00 kb (106.00 mb)
WorkingSet64: 61 196.00 kb (59.00 mb)
GC.GetTotalMemory(true): 2 960.00 kb (2.00 mb)
GC.GetTotalMemory(false): 2 968.00 kb (2.00 mb)

I have read, and read and read an seen videos about memory profiling, but i can't find any problem when i do the profiling of my application. I use ANTS Memory profiler 8 and get this result when i refresh the startpage one time after the build: a

When i look at the Summary, .NET is using 41.65 MB of 135.8 MB total private bytes allocated for the application. This values gets bigger and bigger for each refresh. Is that normal? When i refresh 8 times i get this: .NET is using 56.11 MB of 153 MB total private bytes allocated for the application.

Where should i start? What could be the problem that use so much memory? Is 300 mb to low for memory?

1
  • 1
    It all depends on what your code is doing. Make sure you're calling Dispose on everything. If you have database connections, ensure you close those in your Dispose chain. Commented Mar 26, 2014 at 18:53

2 Answers 2

1

This is undoubtedly due to a memory leak in your code, likely in the form of not disposing/closing connections to something like a queue or database. Profiling aside, review your code and ensure that you're closing/disposing all appropriate resources: your problem should then relieve itself.

Sign up to request clarification or add additional context in comments.

Comments

0

There was some db connections that not was disposed. Then i have a class which removes Etags, like this:

public class CustomHeaderModule : IHttpModule
{
    public void Dispose() { }

    public void Init(HttpApplication context)
    {
        context.PreSendRequestHeaders += OnPreSendRequestHeaders;
    }

    void OnPreSendRequestHeaders(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Headers.Remove("ETag");
    }
}'

Must i remove the new event i add in the Init function? Or will the GC fix that?

And i have a lot of this:

Task.Factory.StartNew(() =>
{
   Add(...);
});

But i don't dispose them in my code. Will the GC fix that or should i do on a other way?

1 Comment

I know I am necromanting this, but for random googlers: no, GC will not magically fix any leak. GC (this is oversimplification! But I think good enough to grasp the concept of GC...) only mark unreachable objects (this.p = new Person(); this.p = null; - that new instance of Person is now unreachable) as free memory (btw but not in OS, C# will hog memory for further use). Calling Dispose() should release stuff like this Person, so they can be marked for GC. If you forget to call Dispose(), stuff are still reachable and will not be marked for GC -> you have memory leak.

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.