我有一个 C# 应用程序,它在尝试分配 ByteArray(不是很大,通常是 ~400-500kb)时偶尔会抛出 OutOfMemoryException。与多个 WCF 服务通信,但是我不确定这是否会导致问题。我们边走边打印内存使用情况,但没有什么明显的错误。该应用程序资源繁重,其内存使用率很高,但没有高到我们得到 OOE 的程度。
CLR 有问题是否存在限制?你知道为什么我们会看到这个异常吗?可能是由于 WCF 配置造成的吗?(例如 maxBuffer 属性等)
2013-02-27 12:01:38,489 [54] INFO - Counters: CPU: 215, Gen0: 6291456, Gen1: 482488, Gen2: 8.201334E+08, LOH: 4.410252E+08, .Net: Private Bytes: 1423708160, Paged: 1424003072,
2013-02-27 12:01:43,504 [34] INFO - Counters: CPU: 291.2773, Gen0: 4194300, Gen1: 1232084, Gen2: 8.494915E+08, LOH: 4.579806E+08, .Net: Private Bytes: 1469743104, Paged: 1470038016,
2013-02-27 12:01:48,520 [55] INFO - Counters: CPU: 285.6698, Gen0: 6291456, Gen1: 662016, Gen2: 8.767135E+08, LOH: 4.999192E+08, .Net: Private Bytes: 1538347008, Paged: 1538641920,
2013-02-27 12:01:53,536 [55] INFO - Counters: CPU: 218.3801, Gen0: 6020000, Gen1: 296772, Gen2: 8.874388E+08, LOH: 5.055583E+08, .Net: Private Bytes: 1556791296, Paged: 1557082112,
System.InsufficientMemoryException: Failed to allocate a managed memory buffer of 459955 bytes. The amount of available memory may be low. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.ServiceModel.Diagnostics.Utility.AllocateByteArray(Int32 size)
--- End of inner exception stack trace ---