0

I have a C# application which occasionally throws an OutOfMemoryException whilst trying to allocate a ByteArray (not huge, normally ~400-500kb). The communicates with several WCF services, however I'm not sure if this contributes to the issue. We print out memory usage as we go, however there's nothing obviously wrong. The app is resource heavy and its memory usage IS high, but not so high that we get a OOE.

Is there a limit at which the CLR has issues? Do you know why we could be seeing this exception? Could it be due to the WCF configuration?(e.g. maxBuffer properties etc.)

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 ---
GeekMania
  • 15
  • 1
  • 9
trilson86
  • 939
  • 1
  • 9
  • 20
  • 1
    Still, aren't the `Private Bytes: 1556791296, Paged: 1557082112` values a little bit too large? – Alex Filipovici Feb 27 '13 at 12:48
  • Maybe this helps: [http://stackoverflow.com/q/3016446/674700](http://stackoverflow.com/q/3016446/674700). – Alex Filipovici Feb 27 '13 at 12:56
  • This is normal, allocating large buffers from the large object heap will start to fail around 1.5 jiggabytes. You are too close to the danger zone, you'll need to substantially reduce your memory foot-print or switch to 64-bit code. Over-allocating a buffer and re-using it repeatedly can bring temporary relief. – Hans Passant Feb 27 '13 at 13:33
  • Thanks all. Couldn't reduce the footprint or upgrade to x64 (for reasons I won't go into here), so the issue was fixed by using /3gb and /LARGEADDRESSAWARE. We also increased the bufferPoolSize / maxBuffer properties in the WCF config to reduce excessive ByteArray allocations. – trilson86 Mar 01 '13 at 17:11

0 Answers0