您个人在 Java 或 .NET 等托管环境中使用的最大堆是多少?你遇到了哪些性能问题,你最终得到的收益是否会随着堆的增大而递减?
5 回答
I work on a 64-bit .Net system that typically uses 9-12 GB, and sometimes as much as 20GB. I have not seen any performance problems even while garbage collecting, and I have been looking hard as I was not expecting it to work so well.
An earlier version hung on to some objects for too long resulting in occasional GCs that freed up 3GB+. Even then, there was no noticeable impact on performance. The system is running on a 16-core server with 32GB RAM, which probably helps...
在 .Net 中,在 Windows 32 位上,在事情开始变得非常糟糕(内存不足异常)之前,您只能真正达到大约 1.4 GB 的内存使用量。这是由于 32 位窗口的限制,该限制将单个进程限制为使用超过 2 GB 的 RAM。您可以在 boot.ini 中添加 /3GB 开关,但这只会让您更进一步。如果你想使用大量内存,你应该认真考虑在 64 位版本的 windows 上运行。
I currently have a production application with 6 GB of memory. You'll need a 64-bit box as well for the JVM to be able to address that much. The garbage collector is really the only thing (that I've found so far) where performance degrades with size, and then only if you manually kick off a System.GC, which forces the JVM to bring everything to a screeching halt as it traverses 6 GB worth of objects. Takes a good 20 seconds, too. The default GC behavior does not do this, BTW, you have to be dumb enough to make it do that. Also worth researching JVM tuning at this size.
You can also find things like distributed and clustered JVMs, sorry, don't have any good references as I didn't look into this option too closely, although I did find references to larger installations.
我不确定你所说的堆是什么意思,但如果你指的是使用的内存,我已经用了很多,2GB+。我有一个进行图像处理的网络应用程序,它需要将 2 个大型扫描文件加载到内存中进行分析。
存在性能问题。Windows 会换出大量内存,然后会产生大量页面错误。一次不需要超过 2 个图像,因为所有请求都获得了这些图像(我一次只允许每个图像集 1 个会话)
例如,为初始查看设置文件大约需要 5 秒。在内存中进行简单的分析和缩放会相当快,大约为 0.1 到 0.5 秒。
我仍然需要进行优化,所以我最终对文件进行了预处理并将其切成更小的部分,并且只使用当时用户需要的部分。
我在 java 中使用了 2GB 到 5GB 的内存,但通常当我达到 2GB 以上时,我才真正开始考虑内存优化。收益递减可能会有所不同,从因为您有大量内存而在必要时不进行优化,到没有可用于操作系统/磁盘缓存的内存(这可以帮助您的应用程序整体)。
对于 Java,我建议随着时间的推移观察每一代的内存使用情况。您是否创建了很多临时对象或有消耗大量内存的持久对象?知道这些东西后,可以对内存进行很多优化。