What happened to array sizing?!? - page 3

 
Mohammad Hossein Sadeghi:
Most probably you have low resources during runtime.
32 GB RAM
 
linux80s:
32 GB RAM
Available memory size? Not installed RAM!
What is your OS?
 
Mohammad Hossein Sadeghi:
Available memory size? Not installed RAM!
What is your OS?
Linux+Wine 6
 
I had a question, but the MIGHTY janitor-spirit moderator deleted that:
in ArrayResize documentation there is 2.147.483.647 as the maximum number of elements.
But, I cannot set an 25.000x10.000 array. It's only 250.000.000, far less than 2.147.483.647. Why?
ArrayResize - Array Functions - MQL4 Reference
ArrayResize - Array Functions - MQL4 Reference
  • docs.mql4.com
ArrayResize - Array Functions - MQL4 Reference
 
linux80s:
Linux+Wine 6
We've experienced weird things in other OS than Windows, try MQL in Windows.
 
Mohammad Hossein Sadeghi:
We've experienced weird things in other OS than Windows, try MQL in Windows.

Thanks Mohammad.

Maybe I can ask you this: would you check what is approx. the maximum array size that you can define?

For example you have this:

#define arrsize 25000
double array[][10000];
ArrayResize(array,arrsize);

What is the maximum number that you can set instead of the 25.000?

 
linux80s:

Thanks Mohammad.

Maybe I can ask you this: would you check what is approx. the maximum array size that you can define?

For example you have this:

What is the maximum number that you can set instead of the 25.000?

According to documentation, the array elements are limited to (2^31)-1, but in runtime it can't be achieved, it seems the limit is not by elements, but by bytes, the size of char variable type is 1 byte, so I tested the char array.

Sample 1: One-dimensional char array:

void OnStart()
{
   Func1();
}
//+------------------------------------------------------------------+
void Func1(void)
{
   char array[];
   for(int arrsize=2147483647;arrsize>0;arrsize--)
   {
      int new_size=ArrayResize(array,arrsize);
      if(new_size!=-1)
      {
         Print("Array 1st dim size: ",arrsize,", ArrayResize ret value: ",new_size);
         break;
      }
   }
}

Result:

Array 1st dim size: 2139353037, ArrayResize ret value: 2139353037

Sample 2: Two-dimensional char array, 2nd dimension size is 2:

void OnStart()
{
   Func1();
}
//+------------------------------------------------------------------+
void Func1(void)
{
   char array[][2];
   for(int arrsize=2147483647;arrsize>0;arrsize--)
   {
      int new_size=ArrayResize(array,arrsize);
      if(new_size!=-1)
      {
         Print("Array 1st dim size: ",arrsize,", ArrayResize ret value: ",new_size);
         break;
      }
   }
}

Result:

Array 1st dim size: 1069676511, ArrayResize ret value: 2139353022

Sample 3: Two-dimensional char array, 2nd dimension size is 3:

void OnStart()
{
   Func1();
}
//+------------------------------------------------------------------+
void Func1(void)
{
   char array[][3];
   for(int arrsize=2147483647;arrsize>0;arrsize--)
   {
      int new_size=ArrayResize(array,arrsize);
      if(new_size!=-1)
      {
         Print("Array 1st dim size: ",arrsize,", ArrayResize ret value: ",new_size);
         break;
      }
   }
}

Result:

Array 1st dim size: 713117672, ArrayResize ret value: 2139353016

Reason: