0

In my C# app I use gcAllowVeryLargeObjects because I am doing image processing with large datasets, resulting in extensive RAM usage. Now I want to write some UnitTests and I am running into the same situations I had without gcAllowVeryLargeObjects.

My setup is about reading JSON files containing large 1D byte arrays using Newtonsoft.Json. The initial error I had, was a classic ObjectOutOfMemoryException when deserializing the file. The ExceptionMessage was: Array Dimensions exceeded supported Range.

I got that managed using <gcAllowVeryLargeObjects enabled="true"/> and now Newtonsoft.Json does not have any issues. But for the UnitTest I don't have any clue how to set this runtime parameter. Hopefully one of you dudes has an idea.

NilesDavis
  • 69
  • 1
  • 3

2 Answers2

1

Keep in mind that this only expands the total memory footprint of the array in question. You are still limited to the standard UInt32 index size. If your array has some 2.14 billion plus data points, it will still error out because you'll exceed the number of entries allowed into the array.

Brett R
  • 11
  • 1
0

I can't find a definitive answer. It might be possible to set it using a .runsettings file:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <RunConfiguration>
    <runtime>  
      <gcAllowVeryLargeObjects enabled="true" />  
    </runtime>  
  </RunConfiguration>
</RunSettings>
Kevin
  • 398
  • 2
  • 7
  • Sorry for the enormous delay, but I finally could test it. I was not aware that this .runsettings do exist, but the approach is not bad. Unfortunately it does not work as expected. Running as well as debugging the Test leads to the exception expected when gcAllowVeryLargeObjects is disabled. But I'll dig a little concerning .runsettings, hopefully there will be a solution – NilesDavis May 31 '21 at 10:06