Thursday, March 22, 2012

System.OutOfMemoryException

I just got this error on my server even though I have lots of available memory. I did notice that my aspnet_wp.exe was at 648MB. How can I get the bugger back down to a lower MB usage without restarting the asp worker processor?Not sure why you are getting the error when you have available memory, maybe you incorrectly customised the garbage collection?

As far as reducing memory usage, well there could be multiple efficiencies possible in your code, there is no magic bullet :(.

Cheers
Martin
No, I didn't customize the garbage collection. I wouldn't even knwo where to begin on how to do such a thing. I am looking into my code trying to see where I might have efficiency problems. Mainly looking at if I dispose of all my object correctly. If I dispose of my objects in the finally block will that get remove them from memory?

Thanks.
Garbage collection usually manages the clean up of .Net objects. Although it is possible, MS recommends that you do not modify the behavior of the garbage collector so don't let me put bad ideas into your head :).

As far as disposing of objects, you usually only need to woory about that for unmanaged objects (legacy). How large is your code, can you put up a sample?

Cheers
Martin
Are you storing a lot of stuff in cache or session variables?
Rethink your design or let somebody do a code review ...
I would like to do a code review. What is the best way to do this?

0 comments:

Post a Comment