since a few days my tester need a lot of memory. I never had a problem with memory since these few days. I deactivated all cores except 1.
The system had run out of memory very quick, after reducing a lot of Prints() in the EA and using a shorter EA-Name (!?) I think I can run an optimization again.
But only 1 core, only 2 years testing 19GB of memory usage is still crazy.
I did never had these problems, I tested periods of 20 years without problems, why now? Where are these problems coming from?
since a few days my tester need a lot of memory. I never had a problem with memory since these few days. I deactivated all cores except 1.
The system had run out of memory very quick, after reducing a lot of Prints() in the EA and using a shorter EA-Name (!?) I think I can run an optimization again.
But only 1 core, only 2 years testing 19GB of memory usage is still crazy.
I did never had these problems, I tested periods of 20 years without problems, why now? Where are these problems coming from?
1. Looking here I have the latest (stable?) release: https://www.metatrader5.com/en/releasenotes
EDIT: Updated build 2776 (beta). Same issue.
2. How I should find a memory leak? My EA is not saving a lot of data. And why the memory usage is increasing over time, it did not stop anywhere, unlesss the Optimization is stopped memory consumption is increasing till the end.
Why MT5 is written like this? I don't know any other application which causes system crashes like this in 2021.
Update: 11.02.2021 6:00: By reducing a lot of prints I reduced the memory consumption for a single tester run from 1-2GB to 400-500MB but running in optimization mode there is no difference. Every host gets killed.
Revised Popup Prices window which allows viewing financial symbol prices on any screen size. The window now supports multi-column presentation, enabling the efficient utilization of screen space.
1. Looking here I have the latest (stable?) release: https://www.metatrader5.com/en/releasenotes
EDIT: Updated build 2776 (beta). Same issue.
2. How I should find a memory leak? My EA is not saving a lot of data. And why the memory usage is increasing over time, it did not stop anywhere, unlesss the Optimization is stopped memory consumption is increasing till the end.
Why MT5 is written like this? I don't know any other application which causes system crashes like this in 2021.
Update: 11.02.2021 6:00: By reducing a lot of prints I reduced the memory consumption for a single tester run from 1-2GB to 400-500MB but running in optimization mode there is no difference. Every host gets killed.
This line creates the CurrentBarData instance cb, then creates an anonymous instance via new, and assigns it by value to cb. After this line, there's no access to that anonymous instance left. Dang, memory leak.
I suggest to add Print statements or use the debugger with a breakpoint in the constructor to see how this happens.
When you create class object pointers with new you should always ensure they are deleted when you are finished with them, at the very least in Deinit() to avoid memory leaks.
Also, do not try and delete the pointer if it does not exist as that will give you another set of problems.
If you don't know how trade classes are constructed, and are scared of the words "Object Oriented Programming", then this article is for you. In fact, you do not need to know the details to write your own module of trading signals. Just follow some simple rules. All the rest will be done by the MQL5 Wizard, and you will get a ready-to-use trading robot!
lippmaje: This line creates the CurrentBarData instance cb, then creates an anonymous instance via new, and assigns it by value to cb. After this line, there's no access to that anonymous instance left. Dang, memory leak.
I suggest to add Print statements or use the debugger with a breakpoint in the constructor to see how this happens.
Hello,
"anonymous instance via new" - How would someone access it? Isn't it always a memory leak? Why the language allows that?
When you create class object pointers with new you should always ensure they are deleted when you are finished with them, at the very least in Deinit() to avoid memory leaks.
Also, do not try and delete the pointer if it does not exist as that will give you another set of problems.
Hello,
how would I access something without an handle or variable name?
the line is now:
CurrentBarData cb();
I have to say, I really don't like this syntax. cb is a variable name, not a function - why "()" on the variable name and not on the class name or constructor?
I also find out accessing some methods multiple times take longer than saving it to a variable and access it from there:
datetime time = TimeTradeServer();
Pro of all this searching: The EA got really fast. I reduced the running time of the EA to about 10%.
I am softwareengineer for 15 years, so I wrote the line like I would do in php or java.
Why the object is not completely removed from memory and how I write this line so I REALLY, REALLY get a new clean object ?
That is not an assignment; it's initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.
They are initialized once on program load.
They don't update unless you assign to them.
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
Terminal starts.
Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
OnInit is called.
For indicators OnCalculate is called with any existing history.
Human may have to enter password, connection to server begins.
New history is received, OnCalculate called again.
New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Hello,
since a few days my tester need a lot of memory. I never had a problem with memory since these few days. I deactivated all cores except 1.
The system had run out of memory very quick, after reducing a lot of Prints() in the EA and using a shorter EA-Name (!?) I think I can run an optimization again.
But only 1 core, only 2 years testing 19GB of memory usage is still crazy.
I did never had these problems, I tested periods of 20 years without problems, why now? Where are these problems coming from?
System: ASRock B450M Pro4 / AMD Ryzen 3400G / 64GB
Problems of the high memory usage: freezing or self-killing of each application, second screen blanks, nothing clickable, sometimes unwanted reboot.
Do somebody have experience with memory consumption like this and get it solved?
yours sincerely
sb
Hello,
since a few days my tester need a lot of memory. I never had a problem with memory since these few days. I deactivated all cores except 1.
The system had run out of memory very quick, after reducing a lot of Prints() in the EA and using a shorter EA-Name (!?) I think I can run an optimization again.
But only 1 core, only 2 years testing 19GB of memory usage is still crazy.
I did never had these problems, I tested periods of 20 years without problems, why now? Where are these problems coming from?
System: ASRock B450M Pro4 / AMD Ryzen 3400G / 64GB
Problems of the high memory usage: freezing or self-killing of each application, second screen blanks, nothing clickable, sometimes unwanted reboot.
Do somebody have experience with memory consumption like this and get it solved?
yours sincerely
sb
Two options:
Two options:
Hello,
1. Looking here I have the latest (stable?) release: https://www.metatrader5.com/en/releasenotes
EDIT: Updated build 2776 (beta). Same issue.
2. How I should find a memory leak? My EA is not saving a lot of data. And why the memory usage is increasing over time, it did not stop anywhere, unlesss the Optimization is stopped memory consumption is increasing till the end.
Why MT5 is written like this? I don't know any other application which causes system crashes like this in 2021.
Update: 11.02.2021 6:00:
By reducing a lot of prints I reduced the memory consumption for a single tester run from 1-2GB to 400-500MB but running in optimization mode there is no difference. Every host gets killed.
Hello,
1. Looking here I have the latest (stable?) release: https://www.metatrader5.com/en/releasenotes
EDIT: Updated build 2776 (beta). Same issue.
2. How I should find a memory leak? My EA is not saving a lot of data. And why the memory usage is increasing over time, it did not stop anywhere, unlesss the Optimization is stopped memory consumption is increasing till the end.
Why MT5 is written like this? I don't know any other application which causes system crashes like this in 2021.
Update: 11.02.2021 6:00:
By reducing a lot of prints I reduced the memory consumption for a single tester run from 1-2GB to 400-500MB but running in optimization mode there is no difference. Every host gets killed.
Show your MQL5 code.
Show your MQL5 code.
Hello, thank you for your time.
I found the problematic line:
changing to
solves to memory problem.
I am softwareengineer for 15 years, so I wrote the line like I would do in php or java.
Why the object is not completely removed from memory and how I write this line so I REALLY, REALLY get a new clean object ?
I suggest to add Print statements or use the debugger with a breakpoint in the constructor to see how this happens.
When you create class object pointers with new you should always ensure they are deleted when you are finished with them, at the very least in Deinit() to avoid memory leaks.
Also, do not try and delete the pointer if it does not exist as that will give you another set of problems.
This line creates the CurrentBarData instance cb, then creates an anonymous instance via new, and assigns it by value to cb. After this line, there's no access to that anonymous instance left. Dang, memory leak.
I suggest to add Print statements or use the debugger with a breakpoint in the constructor to see how this happens.
Hello,
"anonymous instance via new" - How would someone access it? Isn't it always a memory leak? Why the language allows that?
When you create class object pointers with new you should always ensure they are deleted when you are finished with them, at the very least in Deinit() to avoid memory leaks.
Also, do not try and delete the pointer if it does not exist as that will give you another set of problems.
Hello,
how would I access something without an handle or variable name?
the line is now:
I have to say, I really don't like this syntax. cb is a variable name, not a function - why "()" on the variable name and not on the class name or constructor?
I also find out accessing some methods multiple times take longer than saving it to a variable and access it from there:
Pro of all this searching: The EA got really fast. I reduced the running time of the EA to about 10%.
But anyway, thank you, to all of you!
solves to memory problem.
I am softwareengineer for 15 years, so I wrote the line like I would do in php or java.
Why the object is not completely removed from memory and how I write this line so I REALLY, REALLY get a new clean object ?
That is not an assignment; it's initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.
They are initialized once on program load.
They don't update unless you assign to them.
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet: