Memory Leaks in ASP.NET

Discussion in 'ASP .Net' started by =?Utf-8?B?RnJhbmsxMjEz?=, Mar 4, 2005.

  1. In my ASP.NET application, we are noticing appreciable memory leaks and the
    main culprit appears to be System.String We use ResourceReader to read in a
    resource file and we close and dispose the resourcereader object also. We
    profiled the application using .NET Memory profiler and it appears that
    garbage collection does not appear to be happening. Even after closing all
    sessions memory for aspnet process remains pegged at the level it was.
    Has anyone run across a similar situation? Any ideas would be greatly
    appreciated.
    =?Utf-8?B?RnJhbmsxMjEz?=, Mar 4, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?RnJhbmsxMjEz?=

    Scott Allen Guest

    So the application leaks? Or it stays at a farily predictable 'high
    water' mark?

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Thu, 3 Mar 2005 16:45:02 -0800, Frank1213
    <> wrote:

    >In my ASP.NET application, we are noticing appreciable memory leaks and the
    >main culprit appears to be System.String We use ResourceReader to read in a
    >resource file and we close and dispose the resourcereader object also. We
    >profiled the application using .NET Memory profiler and it appears that
    >garbage collection does not appear to be happening. Even after closing all
    >sessions memory for aspnet process remains pegged at the level it was.
    >Has anyone run across a similar situation? Any ideas would be greatly
    >appreciated.
    Scott Allen, Mar 4, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?RnJhbmsxMjEz?=

    Homam Guest

    You need be very careful with String objects as you could easily end up
    creating a large number of intermediate junk objects. In most cases, a
    reusable StringBuilder used as a buffer is a better choice.

    Check:
    http://msdn.microsoft.com/library/e...hapt05.asp?frame=true#scalenetchapt05_topic26




    "Scott Allen" <> wrote in message
    news:...
    > So the application leaks? Or it stays at a farily predictable 'high
    > water' mark?
    >
    > --
    > Scott
    > http://www.OdeToCode.com/blogs/scott/
    >
    > On Thu, 3 Mar 2005 16:45:02 -0800, Frank1213
    > <> wrote:
    >
    >>In my ASP.NET application, we are noticing appreciable memory leaks and
    >>the
    >>main culprit appears to be System.String We use ResourceReader to read
    >>in a
    >>resource file and we close and dispose the resourcereader object also. We
    >>profiled the application using .NET Memory profiler and it appears that
    >>garbage collection does not appear to be happening. Even after closing all
    >>sessions memory for aspnet process remains pegged at the level it was.
    >>Has anyone run across a similar situation? Any ideas would be greatly
    >>appreciated.

    >
    Homam, Mar 4, 2005
    #3
  4. Thanks to both of you for your replies.
    at one of our client sites the application virtually became unusable pegging
    the memory over 800 MB. In our tests with .NET Memory profiler the culprit
    appears to be System.String when used with ResourceReader. Our tests also
    indicated that even after all the sessions are closed the aspnet memory
    remained high and never came down even after about 6 hours.

    "Homam" wrote:

    > You need be very careful with String objects as you could easily end up
    > creating a large number of intermediate junk objects. In most cases, a
    > reusable StringBuilder used as a buffer is a better choice.
    >
    > Check:
    > http://msdn.microsoft.com/library/e...hapt05.asp?frame=true#scalenetchapt05_topic26
    >
    >
    >
    >
    > "Scott Allen" <> wrote in message
    > news:...
    > > So the application leaks? Or it stays at a farily predictable 'high
    > > water' mark?
    > >
    > > --
    > > Scott
    > > http://www.OdeToCode.com/blogs/scott/
    > >
    > > On Thu, 3 Mar 2005 16:45:02 -0800, Frank1213
    > > <> wrote:
    > >
    > >>In my ASP.NET application, we are noticing appreciable memory leaks and
    > >>the
    > >>main culprit appears to be System.String We use ResourceReader to read
    > >>in a
    > >>resource file and we close and dispose the resourcereader object also. We
    > >>profiled the application using .NET Memory profiler and it appears that
    > >>garbage collection does not appear to be happening. Even after closing all
    > >>sessions memory for aspnet process remains pegged at the level it was.
    > >>Has anyone run across a similar situation? Any ideas would be greatly
    > >>appreciated.

    > >

    >
    >
    >
    =?Utf-8?B?RnJhbmsxMjEz?=, Mar 4, 2005
    #4
  5. =?Utf-8?B?RnJhbmsxMjEz?=

    Mark Rae Guest

    "Frank1213" <> wrote in message
    news:...

    > We profiled the application using .NET Memory Profiler


    You mean this one: http://www.scitech.se/memprofiler/

    Can you recommend it? Is anyone else using it? Is there a better utility out
    there?
    Mark Rae, Mar 4, 2005
    #5
  6. =?Utf-8?B?RnJhbmsxMjEz?=

    Josh Guest

    Its not likely to be the fault of the string. I bet its the Reader not
    cleaning up. Try killing the reader.


    "Frank1213" <> wrote in message
    news:...
    > In my ASP.NET application, we are noticing appreciable memory leaks and
    > the
    > main culprit appears to be System.String We use ResourceReader to read
    > in a
    > resource file and we close and dispose the resourcereader object also. We
    > profiled the application using .NET Memory profiler and it appears that
    > garbage collection does not appear to be happening. Even after closing all
    > sessions memory for aspnet process remains pegged at the level it was.
    > Has anyone run across a similar situation? Any ideas would be greatly
    > appreciated.
    Josh, Mar 4, 2005
    #6
  7. We in fact Close,Dispose and even set the reader to null.

    "Josh" wrote:

    > Its not likely to be the fault of the string. I bet its the Reader not
    > cleaning up. Try killing the reader.
    >
    >
    > "Frank1213" <> wrote in message
    > news:...
    > > In my ASP.NET application, we are noticing appreciable memory leaks and
    > > the
    > > main culprit appears to be System.String We use ResourceReader to read
    > > in a
    > > resource file and we close and dispose the resourcereader object also. We
    > > profiled the application using .NET Memory profiler and it appears that
    > > garbage collection does not appear to be happening. Even after closing all
    > > sessions memory for aspnet process remains pegged at the level it was.
    > > Has anyone run across a similar situation? Any ideas would be greatly
    > > appreciated.

    >
    >
    >
    =?Utf-8?B?RnJhbmsxMjEz?=, Mar 4, 2005
    #7
  8. Yes. We used the same one. I am not aware of something better than this.

    "Mark Rae" wrote:

    > "Frank1213" <> wrote in message
    > news:...
    >
    > > We profiled the application using .NET Memory Profiler

    >
    > You mean this one: http://www.scitech.se/memprofiler/
    >
    > Can you recommend it? Is anyone else using it? Is there a better utility out
    > there?
    >
    >
    >
    =?Utf-8?B?RnJhbmsxMjEz?=, Mar 4, 2005
    #8
  9. I agree with Josh. System.String is not going to cause any memory leaks. If
    you abuse it, it can run your memory up quite a bit, but it will come back
    down. On the other hand, ResourceReader is a disposable class that works
    with files. Not closing and/or disposing such a class can cause a memory
    leak.

    Now, I know that you've stated that you close and dispose the
    ResourceReader, but are you sure that you always do so? For example, is the
    close and dispose in a Finally block of a Try/Catch block? If not, an
    exception might prevent the ResourceReader from being disposed properly.

    You might want to look for any other classes that expose unmanaged objects,
    particularly classes that work with File IO.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "Frank1213" <> wrote in message
    news:D...
    > We in fact Close,Dispose and even set the reader to null.
    >
    > "Josh" wrote:
    >
    >> Its not likely to be the fault of the string. I bet its the Reader not
    >> cleaning up. Try killing the reader.
    >>
    >>
    >> "Frank1213" <> wrote in message
    >> news:...
    >> > In my ASP.NET application, we are noticing appreciable memory leaks and
    >> > the
    >> > main culprit appears to be System.String We use ResourceReader to
    >> > read
    >> > in a
    >> > resource file and we close and dispose the resourcereader object also.
    >> > We
    >> > profiled the application using .NET Memory profiler and it appears that
    >> > garbage collection does not appear to be happening. Even after closing
    >> > all
    >> > sessions memory for aspnet process remains pegged at the level it was.
    >> > Has anyone run across a similar situation? Any ideas would be greatly
    >> > appreciated.

    >>
    >>
    >>
    Kevin Spencer, Mar 4, 2005
    #9
  10. =?Utf-8?B?RnJhbmsxMjEz?=

    david youren Guest

    I have a similar problem with a memory leak in .net on a dual xeon
    windows 2003 server. I notice a lot of posts about this leaks on a dual
    xeon, what is your server running?



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    david youren, Mar 11, 2005
    #10
  11. =?Utf-8?B?RnJhbmsxMjEz?=

    sanjeevsai

    Joined:
    May 28, 2009
    Messages:
    2

    Hi,

    we are also facing the problem of memory leak. actually this is because of the infragistics tools for ASP.net. I am also using .net Memory Profile but since I new to this tool, need some resources which could give me insite of the tool. the resouces/material/samples available on the .net memory profiler's site are for win App.

    will appreciate if you could provide something regarding this.
    sanjeevsai, May 28, 2009
    #11
  12. =?Utf-8?B?RnJhbmsxMjEz?=

    mias

    Joined:
    Nov 7, 2012
    Messages:
    2
    Asp.Net Web Profiler

    I only recently dicovered the Asp.Net Web Profiler. It is simply amazing in how you can analize in memory data. It displays the asp.net cache data, application state data and objects, all active user sessions and al session state data in each session with drill down functionality to browse through data and analyze everything.
    mias, Nov 7, 2012
    #12
  13. =?Utf-8?B?RnJhbmsxMjEz?=

    mias

    Joined:
    Nov 7, 2012
    Messages:
    2
    Web Profiler

    If there are still something running in memory you should be able to detect it by running the asp.net web profiler. You can download for free from aspwebprofiler.com
    mias, Mar 17, 2013
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ASP.Confused

    ASP.NET - Detecting memory leaks

    ASP.Confused, Jul 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,726
    Marina
    Jul 16, 2004
  2. James Hunter Ross

    Our memory leaks?

    James Hunter Ross, Oct 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    765
    Bruce Barker
    Oct 20, 2005
  3. Novice
    Replies:
    28
    Views:
    5,061
    Jon Skeet
    Jul 22, 2003
  4. Rob Baker

    asp memory leaks

    Rob Baker, Nov 25, 2003, in forum: ASP General
    Replies:
    3
    Views:
    168
    Egbert Nierop \(MVP for IIS\)
    Nov 26, 2003
  5. Replies:
    4
    Views:
    107
Loading...

Share This Page