.NET 9.0 - gcAllowVeryLargeObjects {"Exception of type 'System.OutOfMemoryException' was thrown."}
Есть в наличии AppConfig:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
<appSettings>
<add key="RomanY" value="Roman Programmer" />
</appSettings>
</configuration>
Еще секцию добавил в machine.config в папку
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
Есть кастомный класс для коллекции превышающей 2 GB с массивом массивов:
public class BulkCollection<T> : IEnumerable<T>, ICloneable
{
private const int ChunkSize = 1000000000;
private readonly T[][] _chunks;
public long Count { get; }
public BulkCollection(long count)
{
Count = count;
long numberOfChunks = count / ChunkSize;
long lastChunkSize = count % ChunkSize;
_chunks = new T[numberOfChunks + (lastChunkSize > 0 ? 1 :0)][];
for (long i = 0; i < numberOfChunks; i++)
{
_chunks[i] = new T[ChunkSize];
}
if (lastChunkSize > 0)
{
_chunks[^1] = new T[lastChunkSize];
}
}
public BulkCollection(BulkCollection<T> bulkcollection)
{
}
public T this[long index]
{
get
{
if (index < 0 || index >= Count)
{
throw new IndexOutOfRangeException();
}
long chunkIndex = index/ChunkSize;
int itemIndexInChunk = (int)(index % ChunkSize);
return _chunks[chunkIndex][itemIndexInChunk];
}
set
{
if (index < 0 || index >= Count)
{
throw new IndexOutOfRangeException();
}
long chunkIndex = index / ChunkSize;
int itemIndexInChunk = (int)(index % ChunkSize);
_chunks[chunkIndex][itemIndexInChunk] = value;
}
}
public IEnumerator<T> GetEnumerator()
{
return new BulkEnumerator<T>(this);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public object Clone()
{
return this.MemberwiseClone();
}
}
In for cycle :
for (long i = 0; i < numberOfChunks; i++)
{
_chunks[i] = new T[ChunkSize];
}
исключение:
Exception of type 'System.OutOfMemoryException' was thrown
System.OutOfMemoryException
Заранее спасибо за любую помощь