限制 .Net CLR 内存使用

发布于 2024-10-05 13:19:55 字数 291 浏览 0 评论 0原文

好的,问题来了。在我们的生产环境 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝海似她心 2024-10-12 13:19:55

模拟低内存/资源系统的一种方法是创建一个系统虚拟机并分配您希望它拥有的特定内存量。 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.

且行且努力 2024-10-12 13:19:55

您的程序是否收到 OutOfMemoryException 与您的计算机上有多少 RAM 无关。 OutOfMemoryException 表示进程已用完虚拟内存,这对于独立于物理 RAM 的每个进程都是相同的

有几个项目会影响进程中的虚拟内存量

  • 32 位进程与 64 位进程
  • /LargeAddressAware 等开关 (文档)

最佳猜测服务器是 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 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文