Possible Solutions to Runtime Error: 4025

 

I was trying some code in the MQL4 backtesting application. This code will not be ran outside of this "backtesting."

Within this code I am using several ArrayResize calls with a large 'new_size' values. I am not using multiple ArrayResize calls because there are many cases where the arrays' size changes, but rather due to the fact there are many arrays (in fact there is just 1 array resize per array). To be more specific, the minimum size I require for each array is 1051200 which is far below the max size for an array which is 2147483647.  There are around ~440 +/- 1. So the total elements expected is in the minimum case is: 462528000 which is still 1684955647 less than the max size for 1 array. 

After some number of these calls,  I realize the ArrayResize calls start to return -1 indicating something went wrong with the resizing. So after using GetLastError(), the error code was 4025 indicating an "Out of memory" error. 

So my question is, is there any way to work around this error without deleting these arrays (each of which are very valuable and I can't discuss their value)? For example is there anyway to allocate more memory to this EA which is actually never going to continuous run in real-time (so there are no risk of the program crashing the terminal), but just get used in the backtesting software?


Thanks in advanced, 

 

You have already "Out of memory" error and you want to allocate more memory to the EA ! Are you understanding what you are doing and asking for ?

MT4 is 32 bit application which can manage only some GB of RAM, deal with it and code your EA more efficiently.

 
Alain Verleyen #:

You have already "Out of memory" error and you want to allocate more memory to the EA ! Are you understanding what you are doing and asking for ?

MT4 is 32 bit application which can manage only some GB of RAM, deal with it and code your EA more efficiently.

Yes I do know what I am asking for, and everything is set up as efficiently as it can within the deviation minor optimizations. Every single array is quintessential to the project I am presently. Most of the datetypes are doubles and ints which means each value in the arrays is 8 bytes in memory (in the upper case). So I am only collecting 3 GB of data in a one time running of the program. Which in my experience is not that much to ask (maybe I am wrong, and you can correct me). 


Hopefully you don't find this statement in bad taste, but your reply is not in the least useful to me.


Instead, could you state things like: 

What is the max memory? How do I collect said parameter/limit?

Does MT4 undershoot the amount of memory it allocates to its features? If so, can we change that without stressing the application too much (maybe even a formalization of what stress is for this application)? 

Are there ways to track how much memory I am using so I can keep track of it without going over specified limits through logging?

Is there a more efficient way to go about doing ArrayResize calls/dynamic array work? 

 
TraderTogami #:

Yes I do know what I am asking for, and everything is set up as efficiently as it can within the deviation minor optimizations. Every single array is quintessential to the project I am presently. Most of the datetypes are doubles and ints which means each value in the arrays is 8 bytes in memory (in the upper case). So I am only collecting 3 GB of data in a one time running of the program. Which in my experience is not that much to ask (maybe I am wrong, and you can correct me). 


Hopefully you don't find this statement in bad taste, but your reply is not in the least useful to me.


Instead, could you state things like: 

What is the max memory? How do I collect said parameter/limit?

Does MT4 undershoot the amount of memory it allocates to its features? If so, can we change that without stressing the application too much (maybe even a formalization of what stress is for this application)? 

Are there ways to track how much memory I am using so I can keep track of it without going over specified limits through logging?

Is there a more efficient way to go about doing ArrayResize calls/dynamic array work? 

I am still thinking you don't understand what you are doing/asking, sorry. There is no bad taste or anything, but if you really need all these arrays, with this size, which I strongly doubt, then there is no solution.

Read the documentation you will find your answers, and show your code if you need coding help.

 
Alain Verleyen #:

I am still thinking you don't understand what you are doing/asking, sorry. There is no bad taste or anything, but if you really need all these arrays, with this size, which I strongly doubt, then there is no solution.

Read the documentation you will find your answers, and show your code if you need coding help.

The apology should me on my end, I have to ask for permission to reveal certain things. If there is nothing we can do, I will read more of the documentation, and try to brainstorm something, thank for making clear that there is no solution to this. 

Reason: