OOP: nested classes and undeleted objects and strings after removing the indi or script - what to do?
Try tracking down the easiest candidate first. Your 1 CManager class is not being deleted.
Usually you would delete the CManager instance in the OnDeinit method
Sigh ..
BTW if I debug the script and stop the debugging I don't get the memory leaks:
2017.04.20 13:13:14.844 Script test_C3virat EURUSD,M1: removed 2017.04.20 13:13:14.829 test_C3virat EURUSD,M1: uninit reason 4 2017.04.20 13:13:14.748 test_C3virat EURUSD,M1: debugging terminated 2017.04.20 13:11:22.907 test_C3virat EURUSD,M1: initialized 2017.04.20 13:11:22.861 Script test_C3virat EURUSD,M1: loaded successfully
Carl Schreiber:
Sigh ..
BTW if I debug the script and stop the debugging I don't get the memory leaks:
Ok, that's a bit odd. However I doubt it's the platform.
You might have to create a test case and post it here (strip out the code as honest_knave suggested)
Carl Schreiber:
Ok, if I delete the Objects in OnDeinit() the de-constructors are called, my understanding was that if the objects are removed they call their destructor themselves - sigh, why do I have a computer if I still have to do everything on my own :(
You would like Java and C#. They have garbage collectors which do much of the work for you.
Ok, if I delete the Objects in OnDeinit() the de-constructors are called, my understanding was that if the objects are removed they call their destructor themselves - sigh, why do I have a computer if I still have to do everything on my own :(
Carl Schreiber: my understanding was that if the objects are removed they call their destructor themselves - sigh, why do I have a computer if I still have to do everything on my own :(
|
|

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I have written a three nested classes:
Now this triumvirate is called either by an indicator and alternatively by a script (mainly for debugging)
Everything works fine so far until I remove the indicator or the script from the chart:
Of course I put in the de-constructor of CManager the deletion of every link to the objects it controls: delete(..);
I even tried to follow the de-construction via DebugBreak() - which is just ignored :(
As well as a Print(__LINE__); as the first order in the deconstruction body to see in which sequence the various de-constructors are called - as you can see in the log: nothing like that. :(
And as the classes do have string arrays (Cmmt[10]) to show their state I put a ArrayFree(Cmmt) in the de-constructor - still I found
8 leaked strings left
Do I make a mistake or shall inform the service desk?
Any hint what to do (may be except don't use nested classes).
Thanks in advance
Calli