Is there someway to limit how much a .NET application will use in terms of memory?
Asked
Active
Viewed 2,756 times
6
-
Please include why you wish to do this. – ChaosPandion May 10 '11 at 21:18
-
1to stop runaway .NET applications hogging all a servers memory – Keith Nicholas May 10 '11 at 21:19
-
It sounds like you're trying to limit the amount of physical RAM a .Net process can acquire correct? – JaredPar May 10 '11 at 21:25
-
See if this answers your question - [Set Windows process (or user) memory limit](http://stackoverflow.com/questions/192876/set-windows-process-or-user-memory-limit) – YetAnotherUser May 10 '11 at 21:26
-
1Jared, yes, I want to make sure no .net app can runaway with a whole bunch of memory. – Keith Nicholas May 10 '11 at 21:27
-
1YAU, thats looking very promising, ie Job Objects... which theres a wrapper at http://jobobjectwrapper.codeplex.com/ – Keith Nicholas May 10 '11 at 21:35
-
having said that, surely there might be a command line tool that launches processes as a job object where you can limit its resource usage – Keith Nicholas May 10 '11 at 21:36
-
What about non-.Net apps running away with a whole bunch of memory? Applications that are expecting to get more memory, for good or bad, will behave unexpectedly if you arbitrarily limit them. Most applications won't gracefully handle out of memory errors, which could lead to all sorts of problems. – Jacob Ewald May 10 '11 at 21:37
-
not too worried about non .net apps, and I'm not worried if the apps crash and burn. well I am worried, but thats the lesser of two evils :) – Keith Nicholas May 10 '11 at 21:40
-
@Keith Nicholas: Are you hosting other applications on the service? If not, it's pointless to set a limit; I can understand if you have multiple services, but you shouldn't set limits arbitrarily, you should measure, measure, measure and make the best determination from there. – casperOne May 27 '11 at 21:36
-
there are a number of services/applications/processes. The box is kind of used for a lot of little processing jobs of various sorts. So there's a mish mash of things going on. – Keith Nicholas May 31 '11 at 03:24
-
@casperOne: I understand his point. I just hit this, a .NET app that didn't actually need more than a few tens of megabytes gobbled over 20gb and effectively froze two VMs. – Loren Pechtel Oct 01 '12 at 03:35
1 Answers
4
Have a look at Process Governer: http://lowleveldesign.wordpress.com/2013/11/21/set-process-memory-limit-with-process-governor/. I wrote this tool to test memory leaks in my applications.

Sebastian
- 3,764
- 21
- 28