Pre loader

.NET OutOfMemoryException on AnyCPU? Read this!

Categories

.NET OutOfMemoryException on AnyCPU? Read this!

Recently a member of the Forums reported receiving an OutOfMemoryException in SciChart when appending 40,000,000 points to a DataSeries.

With .NET4.5, AnyCPU, plenty of RAM and a 64-bit operating system this shouldn’t happen, right? This caught us out too so its worth an article to our user-base.

.NET 4.5 AnyCPU != AnyCPU

In .NET4.5, there is a new project setting next to AnyCPU called Prefer 32-Bit, which is the new default setting, which means “If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code”. Yes, you heard that right. AnyCPU != AnyCPU any more.

Prefer32-Bit

 

Prefer 32-Bit If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.

How to Resolve the OutOfMemoryException in .NET4.5

So, how do we fix this? Simple really:

  • If you compile to x64, the problem goes away entirely. However, you can then only deploy to 64-bit systems.
  • If you compile to AnyCPU using .NET4.5 or above, ensure that you uncheck the Prefer 32-Bit flag.

Find out more in the video below

WatchVideo

Best regards
[SciChart HQ]

By Andrew Burnett-Thompson | Jul 17, 2014
CEO / Founder of SciChart. Masters (MEng) and PhD in Electronics & Signal Processing.Follow me on LinkedIn for more SciChart content, or twitter at @drandrewbt.

Leave a Reply