Restricting .Net CLR memory usage

与世无争的帅哥 提交于 2019-12-07 08:47:46

问题


Ok, so here's the problem. In our production environment (ASP.Net) our servers have a massive amount of memory as well as a massive number of users / sessions. My computer has 8 gigs, and I'm the only user. In production, we're (rarely) getting a System.OutOfMemoryException.

With that background information, here is the question: is it possible to make the CLR think I only have a gig of memory or less? IIRC, there's a command-line option to do this for Java.

Another option is to make some really big objects to fill up memory to simulate low memory conditions. But that requires modifying the assemblies and the huge objects might be cached to disk.

Recommendations? Or other options?


回答1:


One way to simulate a lower-memory/resource system is to create a system virtual machine and allocate the specific amount of memory you want it to have. Both VMWare and MS Virtual Machines have this feature.

Besides a simulation of a lower-resource machine VMs are also a great way to manage your test environments.




回答2:


Whether or not your program recieves an OutOfMemoryException is independent of how much RAM is on your machine. OutOfMemoryException means the process has run out of virtual memory which is the same for every process independent of physical RAM

There are a couple of items which can affect the amount of virtual memory in a process

  • 32 vs 64 bit process
  • Switches like /LargeAddressAware (Documentation)

Best guess is the server is a 64 bit process while the client machine is 32



来源:https://stackoverflow.com/questions/4341047/restricting-net-clr-memory-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!