Hi experts,
when recompiling an indicator I see a couple of (red triangle) messages in the Experts log about x number of objects of my program class undeleted/left from the previous version's deinit
I never used class pointers nor the new operator, I just declare variables of that class, I was expecting these to be automatically deleted when going out of scope
Should I worry?
thanks, let me try to rephrase, can't put a few thousands lines of code here
I defined a class
I have functions defining several of said class variables, using it, they run and terminate correctly
I have a single function receiving a class object by reference, , it runs and terminates correctly
I have NEVER (I repeat: NEVER) new-ed any class object
I have a red flag undeleted objects message in the log at deinit time
if I try to use delete <class_variable> in my code wherever I use said class variables I get a compiler error because class_variable is NOT a pointer
anybody could tell what to look for that could raise that red log message?
thanks
For whoever should stumble in the same issue: I solved by changing the code, now whenever I want to use a class object I define a pointer to it, I "new" it and then I delete it before exiting the function/code section
So, essentially dynamic allocation and memory management do NOT work correctly in MT4, be warned
- www.mql5.com
For whoever should stumble in the same issue: I solved by changing the code, now whenever I want to use a class object I define a pointer to it, I "new" it and then I delete it before exiting the function/code section
So, essentially dynamic allocation and memory management do NOT work correctly in MT4, be warned
I suppose you had the same problem as here.
Forum on trading, automated trading systems and testing trading strategies
Alain Verleyen, 2019.11.29 15:50
It is a compiler bug, resulting in the destructor not being call for temporary object. It has been fixed in recent ME build (around 2230) for mql5. Not sure if (and when) they will make it available for MT4.
A temporary object is created here :
return objtmp;
So actually this bug occurs because you don't use pointers.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi experts,
when recompiling an indicator I see a couple of (red triangle) messages in the Experts log about x number of objects of my program class undeleted/left from the previous version's deinit
I never used class pointers nor the new operator, I just declare variables of that class, I was expecting these to be automatically deleted when going out of scope
Should I worry?