RAM and Expert Advisor Problem.

Manuel Espinosa  
Good Day, fellow programmers, I have a problem.

I have a multi-symbol Expert Advisor (in which only the symbols are added and it automatically uses them without opening the charts) without compilation errors and without creating any objects on the different charts.

The problem happens when I put it to run in demo and/or Real, since the RAM usage starts to increase on a daily-weekly basis while the expert advisor is running, approximately from 100mbs of usage it goes up in about two weeks to 200mbs.

I would like to know if anyone could help me or give a suggestion of what is going on.
Fernando Carreiro  
Manuel Arturo Gonzales Espinosa: Good Day, fellow programmers, I have a problem. I have a multi-symbol Expert Advisor (in which only the symbols are added and it automatically uses them without opening the charts) without compilation errors and without creating any objects on the different charts. The problem happens when I put it to run in demo and/or Real, since the RAM usage starts to increase on a daily-weekly basis while the expert advisor is running, approximately from 100mbs of usage it goes up in about two weeks to 200mbs.I would like to know if anyone could help me or give a suggestion of what is going on.

It seems the EA is building up storage and never releasing it.

Check that you are not growing an array instead of using a ring-buffer so that it rewrites old data instead of continuously growing.

Also if you are using indicators, it might be a good idea to release the handle and establish a new one at regular intervals, for example during weekends if it does not trade then.

EDIT: In my own EAs, I try to use only incremental calculations so as not build up arrays and keep the memory usage as low as possible.

fxsaber  
Manuel Arturo Gonzales Espinosa:
I would like to know if anyone could help me or give a suggestion of what is going on.

To be able to understand the problem, I recommend writing this data to the file every hour.

TimeLocal()
TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE)
TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL)
TerminalInfoInteger(TERMINAL_MEMORY_TOTAL)
TerminalInfoInteger(TERMINAL_MEMORY_USED)
MQLInfoInteger(MQL_MEMORY_LIMIT)
MQLInfoInteger(MQL_MEMORY_USED)
MQLInfoInteger(MQL_HANDLES_USED)
Bars(AllUseSymbols, AllUsePeriods)
Manuel Espinosa  

Hello friends, thanks for answering, it took me a few days trying to solve the problem since it did not appear via code and everything was correct but the problem was caused by the trades that the bot generated daily and were saved in the chart for visualization.

In the same way, I implemented your suggestions and I have more confirmation from the expert, thank you!

It was solved by deactivating the "show trade history" checkbox, but I didn't notice it because since it is a multi-symbol bot and the charts are not opened, these objects are not shown, the chart had to be opened manually to be able to see it.

In the same way I implemented via code a loop that goes through all the open symbols and eliminates these trades history.




Fernando Carreiro  
Manuel Arturo Gonzales Espinosa #: Hello friends, thanks for answering, it took me a few days trying to solve the problem since it did not appear via code and everything was correct but the problem was caused by the trades that the bot generated daily and were saved in the chart for visualization.In the same way, I implemented your suggestions and I have more confirmation from the expert, thank you! It was solved by deactivating the "show trade history" checkbox, but I didn't notice it because since it is a multi-symbol bot and the charts are not opened, these objects are not shown, the chart had to be opened manually to be able to see it.

In the same way I implemented via code a loop that goes through all the open symbols and eliminates these trades history.

I was unaware the that "Show trade history" would generate graphics objects even when the chart was not open. That certainly would consume more memory and probably also slow MetaTrader down during a high frequency of trade operations.

This information is especially useful for those that use a VPS and want to keep the RAM and CPU consumption low.

Thank you for the update!

Reason: