tags:

views:

51

answers:

2

Hi guys,

Is it possible to recover memory lost from w3wp.exe? I thought a session.abandon() should clear up the resources like that? The thing is I have a web application, certain pages make w3wp.exe grow significantly. Like from 40 MB to 400 MB. Now I am going to optimize my code defiantly to reduce this, however for what ever amount the w3wp.exe grows, is there no way to recover the lost memory even when the user has logged out and closed the browser?

I know this worker process will recycle after 30 minutes (default) of idle use, but what if there is no idle use-age for a long time and the worker process still has that portion of memory, it just keeps on growing? Any thoughts people?

A: 

The garbage collector will take care of whatever memory needs to be freed, provided that you dispose things correctly, etc. The GC doesn't immediately kick in every time you call Session.Abandon(), as that would be a major performance hit.

That said, every application has a "normal" memory usage, i.e. a stable memory usage (again, provided you don't have leaks), and this figure is different for every application. 400MB can be a lot or it can be nothing, depending on what your app does. I have apps that hover around 400MB and others around 1.5GB and that's OK as long as memory usage stabilizes somewhere. If you see unbounded memory usage then you most likely have a leak somewhere in your app.

Storing large amounts of data in the in-proc session can also quickly rack up the memory usage. Instead, use a file or a database to store this data.

Mauricio Scheffer
Well basically, I am not at all disposing any objects. I thought the 'using' part of c# should take care of the disposing business? And yes my production deployment does not do a session.abandon(). I just realised that and will be putting that on the code but that may not be of much use since 99.9% of the users dont really bother pressing the logout button, they just simply close the browser.
xeshu
A: 

unless you are leaking the memory, the memory manager will re-use this memory so you should not see the process memory keep growing.

Mike
hmmm re-use, now this is an interesting concept...
xeshu