Many thanks
Hello
It's about memory management. I have been programming MQL4 for 5 years but not done this sort of thing before - recursive calls to an indicator that is likely using plenty of resources each call.
I have a my own built indicator that functions to run a back test on a set of parameters. It dumps the results of the test to a csv file. I'm only testing M15 data over 3 months which is around 6192 bars.
I'm calling the iCustom and change one parameter for each run. There is a loop of about 300 tests to go through. So 30 lines in tha csv file.
After getting to about line 200, the memory space for MT4 has got up to 3.5GB! Then it runs out of memory. I get "Not enough memory for EXE" and "Global Initialization failed". I know this is not related to PC memory which is plenty.
This is a huge size for MT4 process. Something is definately wrong and I'm missing it through my lack of experiance on this topic.
Now the indicator im calling should be issuing the DeInit event as a paramerter has changed. Then a Init() event. I understand the indicator code and logic stay in memory but not the data.
To do a test of memory cleanup I tried this. In the Deinit event I have used a ZeroMemory(buffer); call for each of my 25 buffers that record the results and statistics of the statergy run. This made no difference at all.
With the file access to create the csv, I'm using FileFlush() and FileClose() for each line of results. The when I open the file again I move to the end. I said that just to show there should be no issues from that side of things.
I would be grateful of any help from some kind person with experiance with this technique?
Thank you in anticipation of an anwer. Nigel.
Hello Alain
Thank you for reply/instruction.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
It's about memory management. I have been programming MQL4 for 5 years but not done this sort of thing before - recursive calls to an indicator that is likely using plenty of resources each call.
I have a my own built indicator that functions to run a back test on a set of parameters. It dumps the results of the test to a csv file. I'm only testing M15 data over 3 months which is around 6192 bars.
I'm calling the iCustom and change one parameter for each run. There is a loop of about 300 tests to go through. So 30 lines in tha csv file.
After getting to about line 200, the memory space for MT4 has got up to 3.5GB! Then it runs out of memory. I get "Not enough memory for EXE" and "Global Initialization failed". I know this is not related to PC memory which is plenty.
This is a huge size for MT4 process. Something is definately wrong and I'm missing it through my lack of experiance on this topic.
Now the indicator im calling should be issuing the DeInit event as a paramerter has changed. Then a Init() event. I understand the indicator code and logic stay in memory but not the data.
To do a test of memory cleanup I tried this. In the Deinit event I have used a ZeroMemory(buffer); call for each of my 25 buffers that record the results and statistics of the statergy run. This made no difference at all.
With the file access to create the csv, I'm using FileFlush() and FileClose() for each line of results. The when I open the file again I move to the end. I said that just to show there should be no issues from that side of things.
I would be grateful of any help from some kind person with experiance with this technique?
Thank you in anticipation of an anwer. Nigel.