Memory Issues

Hello all,

I've been trying to profile my ASP.NET application on my application server. I set up 2 counters for aspnet_wp process namely '#bytes in all heaps' and 'process:private bytes'. According to a documentation that i read, '#bytes in all heaps' should be less that 'process: private bytes'. However the '#bytes in all heaps' was far greater than that of the 'process: private bytes'. I'm lead to believe that this indicates a memory leak somewhere. Now, the problem is that i've got 15 ASP.NET applications running on that server and i need to find which application(s) are causing the problem. Please i'll need help on which counters to set up that will enable me pin point the rouge application.

Thanks

Emeka.



Answer this question

Memory Issues

  • SLang

    Hi EmekaAwagu

    Here's a blog entry that can help you track down your OutOfMemoryExceptions and determine where your app is holding onto memory: http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx

    Hope that helps

    -Chris


  • Andrew English

    hi,

    One common memory issue within ASPNET is the session object size, do you store session information What usually happens is that the session is kept alive for 20 minutes (default). Check on the global.asax the OnSessionEnd event, you can put some tracing there to check if this event is triggered when the user stops using your website.

    You can check the active sessions per website using (ASPNET Apps v.1.1 (or 2.0) >> Sessions Active and check the instances (your individual websites) to evaluate that problem.

    Do you use InProc Sessions

    Let's start analysing this area at is the common problem.

    Cheers



  • graFFiti

    Hi,

    You can check if it is a session size problem changing to session model to "StateServer" and switch on the service "ASP.NET State Service". With that little change all your sessions are stored on this server, where you can check the memory consumption for it. (Also will allow you to configure a webgarden on your server ).

    Try to do that just to check if the problem is there, if is not we can look into other places.

    Let me know.

    Cheers



  • mitchwardrop

    Hi,

    Do you store big objects on the session It seems quite high 1Gb only to store login details. The Memory manager will trigger the out of memory when all the collection 2 is full (as it can not collect).

    Which readings do you have in Col 0, 1, 2 and large heap

    Cheers



  • Kea

    Hi,

    I think this is not correct, if you are listing the number of bytes in all heaps within the CLR memory manager it will show the sum of all the generations + large object heap. I don't see the relationship with your process private bytes. Check the following simple scenario:

    1) Object A allocates memory (1Kb) - Gen 0 : 1Kb
    2) Object B allocates memory (2Kb) - Gen 0: 3Kb
    3) You destroy your object A - Gen 0: 3Kb (Size can be the same as the Collection runs when the Gen 0 needs space or triggered)

    Readings: Process Private Bytes: 1Kb
    Bytes in All heaps: 3Kb

    Scenario 2:

    1) Object A allocates memory (1Kb) - Gen 0 : 1Kb
    2) Object A allocates unamanaged memory (10Kb) - Gen 0: 1Kb

    Readings: Process Private Bytes: 11Kb
    Bytes in All heaps: 1Kb

    Both scenarios are valid and do not show a problem. The only statement that I agree is "The difference between the same is the number of bytes committed by unmanaged objects."

    Hope this helps



  • dominick.baier

    Thanks Salvador,

    your reply really helps me, now i know i have to look else where for the problem. I've been having quite a number of 'OutOfMemoryException' on my applications and i've been trying to trace the problem, could you please give me a suggestion on where I should look, which counters to look at. Like i said earlier, i've got 15 ASP.NET apps running on that server and i need to know which one or which ones are causing the problem. The database resides on another server.

    Thanks

    Emeka


  • Stevey

    hello,

    Yes i do store session information although the objects are not large, and i do use InProc sessions. I'd like to believe that the session memory is released after the user stops using the site. I say this because, the site requires users to log on, and if they try to do stuff after their session times out, it tells them to log back in. There are other issues that revolve around session profile which are working well, which leads me to believe that the OnSessionEnd event is being triggered.

    I'll check the active sessions per website as you suggested, would that mean that the site with the most sessions could be the problem Would there be an alternative to storing custom objects than in session and using InProc

    Thanks


  • Dylan Smith

    Hi,

    To comment on your first point. I thought that only InProc process supports the OnSessionEnd event.

    In answer to your questions:

    2) The server doesn't actually run out of memory when i get those exceptions, there's usually about 1GB or more left.

    3) I've got 4GB of memory on the webserver

    5) The amount of memory that the worker process is usually about 0.9GB when i get those exceptions.

    Thanks

    Emeka


  • ctsand

    Hello,

    I'd thought about the StateServer mode, but had refrained from using it because, according to an MSDN article Objects stored in session state must be serializable. I've got customs objects here but they aren't serializable, i guess i'll have to work on making the serializable before i can use any other session mode apart from InProc...i guess there's no way around this...is there . I let you know how it goes. Also how will i be able check the memory consumption on the ASP.NET state service, will there be a counter for it

    Thanks

    Emeka


  • RichHamilton

    Hi,

    It is true what you said, upon serialization for custom objects is solved using the [Serializable] attributte. What it is useful is that the State service runs in a differnt process so simply checking the process memory on the Taskbar will give you the answer.

    Things that you can check:

    1) Clear the session content when you get OnSessionEnd (Session.Clear())
    2) Is your server running out of memory I mean, when you get those exceptions is the server memory very low
    3) How much memory do you have installed on the webserver
    4) Another advantage of StateService is that you can recycle your process (configured on IIS6 when it consumes too much memory) without losing the session information.
    5) When you get those exceptions check the amount of memory that aspnet_wp (1.1) or w3wp (2.0).

    Let me know

    Cheers



  • nobodyman

    Hello,

    I'd thought about the StateServer mode, but had refrained from using it because, according to an MSDN article Objects stored in session state must be serializable. I've got customs objects here but they aren't serializable, i guess i'll have to work on making the serializable before i can use any other session mode apart from InProc...i guess there's no way around this...there . I let you know how it goes. Also how will i be able check the memory consumption on the ASP.NET state service, will there be a counter for it

    Thanks

    Emeka


  • NetDragonKing

    EmekaAwagu wrote:

    According to a documentation that i read, '#bytes in all heaps' should be less that 'process: private bytes'.

    Where does it say that



  • Davids Learning

    Hello,

    Yes i do store objects in session, although i don't think they are that large...

    I've just started the counters on Col 0, 1, 2 and large heap, but for now the current reading are:

    Gen 0: 34,209,792

    Gen 1: 5,087,976

    Gen 2: 65,474,332

    Large heap: 7,783,928

    Thanks


  • I am me

    Dear Mattias

    I found the article at this site: http://www.extremeexperts.com/net/articles/netcounters.aspx

    Thanks


  • Memory Issues