Errors, bugs, questions - page 1593

 
the product recall message comes on the smartphone, in the LC and on top of the μl website it does not.
 


Magic script reverses time ;-)

Magic script reverses time ;-)

 
Vladimir Pastushak:
The smartphone receives a message about a product review, but not on the LC or on the top of the mcl website.
It's always been like that, I remember they even asked to put it on the website because it's strange when they leave feedback, and even if they ask you questions right away and you find out only after 2 months. :-)
 

Not a bug, but can't help but share

Writing

if((!IsRunOnTester() && TimeCurrent() >= D'2016.06.31 23:59'))// для тестировщиков, ограничение работы по времени

Compiler gives out a warning

invalid date *****.mq4 115 46

It also checks for valid string dates, I'm shocked ) (30 days in June)

 

Apparently no one cares about this, but I'll write again.

The real task is to create arrays with a total size of about 100% of free memory, quickly fill them with numbers, perform calculations and release them.

I try to get free memory size with

int mem_free_mb=(int)TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE);

result : 23987 MB, my physical memory is 12141 MB, i.e. half as much.

I understand that this figure is for Martians, but I still believe it and write a script to test it:

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
#define  PARTS 5

   srand(GetTickCount());
//---
   int mem_free_mb=(int)TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE);
   //mem_free_mb=5300;//<--- Столько показывает 'Доступной' в диспетчере задач.
   long mem_for_calc=(long)((double)mem_free_mb*1024*1024);
   long mem_one_part=(long)floor((double)mem_for_calc/PARTS);
   if(mem_one_part>=INT_MAX-1)
      mem_one_part=INT_MAX-1;
//---
   printf("Memory for calc: %0.f MB, parts: %d, part: %0.f MB",mem_for_calc/1024/1024,PARTS,mem_one_part/1024/1024);
   char array1[];
   char array2[];
   char array3[];
   char array4[];
   char array5[];

   int res=ArrayResize(array1,(int)mem_one_part);
   Print("Array1 Resize: ",res);
   if(res<1)return;
   printf("Reserved: %0.f MB",1.0*mem_one_part/1024/1024);

   res=ArrayResize(array2,(int)mem_one_part);
   Print("Array2 Resize: ",res);
   if(res<1)return;
   printf("Reserved: %0.f MB",2.0*mem_one_part/1024/1024);

   res=ArrayResize(array3,(int)mem_one_part);
   Print("Array3 Resize: ",res);
   if(res<1)return;
   printf("Reserved: %0.f MB",3.0*mem_one_part/1024/1024);

   res=ArrayResize(array4,(int)mem_one_part);
   Print("Array4 Resize: ",res);
   if(res<1)return;
   printf("Reserved: %0.f MB",4.0*mem_one_part/1024/1024);

   res=ArrayResize(array5,(int)mem_one_part);
   Print("Array5 Resize: ",res);
   if(res<1)return;
   printf("Reserved: %0.f MB",5.0*mem_one_part/1024/1024);

   uint gtc=GetTickCount();
   for(int i=0;i<mem_one_part;i++)
     {
      char ch=(char)rand();
      array1[i]=ch;
      array2[i]=ch;
      array3[i]=ch;
      array4[i]=ch;
      array5[i]=ch;
     }
//---
   printf("Spent time: %d ms",GetTickCount()-gtc);
  }

I get a logical result - it is impossible to allocate array3 because memory has run out.

Then I uncomment line, where I specify how much memory is available now:

mem_free_mb=5300;//<--- Столько показывает 'Доступной' в диспетчере задач.

After that the script runs successfully.

I don't want to be a nuisance to developers, but it's important to know how much memory is available.

Please make it possible to know it through TerminalInfoInteger.

 

Are you aware that in most cases you will not be able to retrieve all available memory?

There is such a thing as memory fragmentation. You've decided to split all the memory into 5 fragments - and the system doesn't have a single uninterrupted fragment of memory of the size you need.

 
Slawa:

Are you aware that in most cases you will not be able to retrieve all available memory?

There is such a notion - memory fragmentation. You have decided to divide all the memory into 5 fragments - but the system doesn't have a single continuous piece of memory of the size you need.

1. Can you first find out what the TERMINAL_MEMORY_AVAILABLE parameter means physically ?

2. Regarding fragments, I think this should be handled by the Windows memory manager, not the programmer.

I need to know how much I can use at a given moment, for example, I want to use 50% of available memory.

Another real task is the CopyTicks request. If you request more ticks than available memory you get 'out of memory'.

 
Andrey Voytenko:

Another real challenge is the CopyTicks request. If you request more ticks than available memory you get 'out of memory'.

Alternatively, unload the data to a file and take it from there in the required segments
 
coderex:
Alternatively, upload the data to a file and take the required segments from there

That's slow for me. I want to do everything through memory. Actually it's being done now, but I have to call GlobalMemoryStatusEx to find out the size of available memory.


	          
 
Andrey Voytenko:

This problem is especially acute when optimizing on cloud agents, whose capabilities you know nothing about from the beginning. It is impossible to determine the real amount of available memory there, neither through MQL, nor through WinApi (because dll calls are forbidden).

It's really unclear what practical sense TERMINAL_MEMORY_AVAILABLE has then? Why would we introduce it if it makes us neither happy nor unhappy?

Reason: