Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1557
  • Last Modified:

ASP.NET Memory Leak

We've got an IIS memory leak on Windows Server 2008 R2 64-bit.

The memory usage climbs steadily to 3 GB.

I've used the ANTS memory profiler to see what is happening and have a lot of memory held by _TimerCallback where  System.Threading.TimerCallback calls System.Web.Caching.CacheExpires.

We're not aware of any specific caching code in the app, so this seems to be something IIS is doing.

Can anyone suggest what the cause might be?
0
purplesoup
Asked:
purplesoup
5 Solutions
 
StephanLead Software EngineerCommented:
The most memory usage mostly come from data or files. Check if you have any code that receives huge resources and put it in cache and stuff. Or maybe opening a file  and not closing it?
0
 
purplesoupAuthor Commented:
Thanks for your comment.

The thing is - this is a huge app - I need to have something more specific to look for - in particular I don't understand why the main classes left in memory appear to have come from this callback to System.Web.Caching.CacheExpires - particularly as I say there is no specific caching code in the app itself, so it look as if this is something IIS is doing.
0
 
btanExec ConsultantCommented:
May not be necessary be caching but can be objects created with each timercallback taken as argument. Memory leak is common when there is loop around creation of objects and making it even more complex when the argument to the new object has callback based variable...just quick thoughts

http://stackoverflow.com/questions/11031041/memory-leak-timercallbacks-objects-referenced-by-root

Sometimes there is also static instance  involved in such creation that can be slowly leaking the memory. Best practice is used static method where possible. Here is one article for info

 http://blogs.msdn.com/b/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ted BouskillSenior Software DeveloperCommented:
IIS is actually a very simple application.  All IIS does is either respond with static pages (HTML) or relay page requests to server side code.

Leaks are always due to the server side code.  It will take time but you'll have to find an object that has not released memory correctly.
0
 
purplesoupAuthor Commented:
Well the only code I could fine with timercallback was log4net - I can try turning it off. Anyone know how to do that? This is what I found and is what I'm going to try:

http://logging.apache.org/log4net/release/faq.html

How do I completely disable all logging at runtime?

Setting the Threshold on the Hierarchy to Level OFF will disable all logging from that Hierarchy. This can be done in the log4net configuration file by setting the "threshold" attribute on the log4net configuration element to "OFF". For example:

<log4net threshold="OFF" />
0
 
Kamal KhaleefaInformation Security SpecialistCommented:
are you using virtual machine ?

if yes virtual always consumes memory

try to make sure that you are closing all the connections with the database

and try to comment the threading and try again
0
 
btanExec ConsultantCommented:
Actually I am thinking of even disabling the event handler method for all timecallback, maybe simply with another objection within that function and see if the "leaks" still exist. Just trying to be make sure we are "barking on the right tree".

I do not recommend logging to be disable where possible as this is security requirement, the key is how to offload this instead of having the code to perform it. of course if we are saying debugging log, that should be well coded with debug option set off and release build to eliminate all this.

One challenge I have in the past is the stage of optimisation which removed codes that inadvertently introduced and remove codes that missed logs and orphan codes. Have exception handler checks as well as they can introduce "leak" indirectly
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now