限制 .Net CLR 内存使用
好的,问题来了。在我们的生产环境 (ASP.Net) 中,我们的服务器拥有大量内存以及大量用户/会话。我的电脑有 8 个千兆位,而我是唯一的用户。在生产中,我们(很少)遇到 System.OutOfMemoryException。
有了这些背景信息,问题就来了:是否有可能让 CLR 认为我只有 1 GB 或更少的内存? IIRC,有一个命令行选项可以为 Java 执行此操作。
另一种选择是制作一些非常大的对象来填充内存以模拟内存不足的情况。但这需要修改程序集,并且巨大的对象可能会缓存到磁盘上。
建议?或者其他选择?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
模拟低内存/资源系统的一种方法是创建一个系统虚拟机并分配您希望它拥有的特定内存量。 VMWare 和 MS 虚拟机都具有此功能。
除了模拟低资源机器虚拟机之外,也是管理测试环境的好方法。
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.
您的程序是否收到
OutOfMemoryException
与您的计算机上有多少 RAM 无关。OutOfMemoryException
表示进程已用完虚拟内存,这对于独立于物理 RAM 的每个进程都是相同的有几个项目会影响进程中的虚拟内存量
最佳猜测服务器是 64 位进程,而客户端计算机是 32 位进程
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 RAMThere are a couple of items which can affect the amount of virtual memory in a process
Best guess is the server is a 64 bit process while the client machine is 32