Closed pavlexander closed 3 years ago
the issue is related to the fact that byte array cannot hold more than
int byteMaxSize = 2_147_483_591;
number of elements in it.. (tested on framework 4.7.2), so the following line fails:
var buffer = new byte[bytes * total]; // here
Buffer.BlockCopy(matrix, 0, buffer, 0, buffer.Length);
reader.Write(buffer, 0, buffer.Length);
if you want to fix it - you need to write a logic that would write the data in chunks, in cases when the bytes * total
value exceeds the maximum allowed number of elements in byte array..
There might be other places that require a fix, I haven't checked..
some info here: https://stackoverflow.com/questions/1391672/what-is-the-maximum-size-that-an-array-can-hold
code to reproduce:
static void Main(string[] args)
{
// for .Net framework I set App.config: gcAllowVeryLargeObjects = True
// for .Net Core I set env: COMPlus_gcAllowVeryLargeObjects = 1
Console.WriteLine("Hello World!");
var testArray = new double[719118, 61, 7];
long doubleArrayTotalSize = testArray.GetLength(0) * testArray.GetLength(1) * testArray.GetLength(2);
var byteArrayTotalSize = 8 * doubleArrayTotalSize;
long byteArrayMaxSize = 2_147_483_591;
var noError = new byte[byteArrayMaxSize];
var error = new byte[byteArrayTotalSize]; // 2_456_507_088
//Buffer.BlockCopy(matrix, 0, buffer, 0, buffer.Length);
//reader.Write(buffer, 0, buffer.Length);
Console.WriteLine("done!");
}
I am trying to save the 3D array of doubles of size
{double[719118, 61, 7]}
Since it's a 64 bit application and I have plenty on RAM - I can operate with arrays of such size OK. But the numpy throws following error when saving to file:
Is there a way to bypass/fix this issue?
It seems like
numpy
has no problems converting standard 3D array intonumpy
array.. but saving it is impossible.. so both save method overloads throw an exception.NumSharp 0.20.5
.Net Core 3.1
x64 appwin 10 x64
VS 2019