Memory exception - page 2

 
Michael Charles Schefe #:

use of new and delete are beyond my current mql5 coding skills. I have only used if,else and a single loop -- and called a couple indicators as resources; the indicators are nested code also; which is about the limits of my mql5 coding skills. I am sure that I could learn more if i had the time, however I do not.

But all seems to work, no errors in weeks before this, of the eas running well. Each ea is less than 900 lines, devided into at least 10 functions -- yes I intend to break it up a bit more. This is only 2 eas, 1 ea manages ALL trades and open trades on the same chart, while a 2nd ea is on all the other 15 charts that only open trades.

i have just now finished running a debug on both eas, and on both terminals without any exclamation lines or red errors. There are 0 messages or errors in experts and journal tabs that are abnormal.

Is there anything you would suggest that I do to analyse mt5 or the system before I declare the issue was a "one off"???

As you said, mt5 4355 is a beta version (the latest available for me is 4350). Try the stable version instead.


Also, if you can, show us an example of your indicator's code. It doesn't need to be the real code.

You said you use some for loops, ifs, etc. Let's say your code is like this:


for(int current_bar=0; current_bar<rates_total;++current_bar)
{
        int handle = iMA(...);

        // you do something with the handle, but never release it
}


In this case, you'll have a memory leak. This code creates an indicator thousands or millions of times and never release its handle. Your memory usage will just increase to infinity - in this case, I suppose MT5 will release those handles automatically at some point, but that's just speculation. If so, you may have some memory errors (just a thought). Arrays, pointers, handles, etc, can all cause temporary memory leaks (while the MQL5 program is running) and thus allocation errors.

Finally, if possible, try to reproduce the same metatrader environment on another computer and check if the error persists. If it does, there's certainly something wrong related to your EAs/indicators; if it doesn't, the problem is your computer/system. 

It's very likely that this sort of error is something that probably will not be solved in hours, but in a few days/weeks after a lot of testing to figure out the real source of the issue.

 
Emanuel Cavalcante Amorim Filho #:

Thanks for the all the points to check up. I will get around to all of them in coming days, maybe even a week to get round to all of them, but be assured that I will get around to all of them -- as this error, as you hinted -- is just as likely to be some sort of system fault, rather than just a mt5 issue.

today i will check with broker what the minimum version i can have running. If anyone has knowledge of what the latest stable version is, then please inform me below!

I will post snippets of the loop; as well as the indicators I am using later today also. But these are just from codebase which I have used for years without any errors.

 

Main EA is attached.

You will also find the indicators. Both found on codebase.

Please be as critical as you can with my source code and your feedback; just try to be nice and civil with your wording as I am rather timid and intraverted already!

Note how I added all files into the Experts folder.

Note II the 2nd ea mentioned in previous comments is exactly same as the first ea file -- I just uncommented the trade management lines.

----------------------------

anxiously awaiting all feedback.

NOTE Specially. I plan to limit the loop -- just have not got around to doing it yet.
 

NOTE I think I know the culprit, or at least "half" of the culprit -- the 2nd half being MT5

I use a program that improves cacheing in windows; cuts IOs down to 20% and also has a memory cache feature that apparently clashes with memory hogs like MT5. I discussed the errors above with the program support. They claim that when memory is over half used, it releases memory back to windows when other programs demand more from windows, however, apparently this process may be too slow to happen for some programs. We suspect that mt5 is one of these programs.

But I will continue to do all the checks suggested above just in case the cause of these issues are more rooted in windows and the rest of the system.

 
Emanuel Cavalcante Amorim Filho #:
As you said, mt5 4355 is a beta version (the latest available for me is 4350). Try the stable version instead.


Also, if you can, show us an example of your indicator's code. It doesn't need to be the real code.

You said you use some for loops, ifs, etc. Let's say your code is like this:



In this case, you'll have a memory leak. This code creates an indicator thousands or millions of times and never release its handle. Your memory usage will just increase to infinity - in this case, I suppose MT5 will release those handles automatically at some point, but that's just speculation. If so, you may have some memory errors (just a thought). Arrays, pointers, handles, etc, can all cause temporary memory leaks (while the MQL5 program is running) and thus allocation errors.

Finally, if possible, try to reproduce the same metatrader environment on another computer and check if the error persists. If it does, there's certainly something wrong related to your EAs/indicators; if it doesn't, the problem is your computer/system. 

It's very likely that this sort of error is something that probably will not be solved in hours, but in a few days/weeks after a lot of testing to figure out the real source of the issue.

wheer would you put indicatorRelease in indicator: MACD_Tema?