whitebloodcell:
I am getting messages of
"XXX bytes of leaked memory"
"YYY objects of type DbleLess left"
"ZZZ undeleted objects left"
The function is called from the main OnStart() loop. I thought I was deleting the objects - so why the memory leak?
void UpdateNearestLevels(int SupOrRes,const int Bar,double& SP_Levels[],double& SP_Times[],double& OppSP_Levels[],double& OppSP_Times[], double& Next_Level[],const double &O[],const double &H[],const double &L[],const double &C[],const datetime &T[]) { if( Bar<2*ActualBarsEitherSide) { return; } Comparable* Operator1; Comparable* Operator2; if(SupOrRes==Res) { Operator1 = new DblGreater; Operator2 = new DblLess; } else { Operator1 = new DblLess; Operator2 = new DblGreater; } /* Rest of code here */ delete Operator1; Operator1=NULL; delete Operator1; Operator2=NULL; }
You seem to be deleting Operator1 twice at the end of your code. That might be causing the leak.
Candles:
(Facepalm). Thanks for pointing that out! My problems always seem to be simple things like this...
You seem to be deleting Operator1 twice at the end of your code. That might be causing the leak.
whitebloodcell:
(Facepalm). Thanks for pointing that out! My problems always seem to be simple things like this...
Me too, been there, done that and still fall victim to this at times :)
(Facepalm). Thanks for pointing that out! My problems always seem to be simple things like this...
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
I am getting messages of
"XXX bytes of leaked memory"
"YYY objects of type DbleLess left"
"ZZZ undeleted objects left"
The function is called from the main OnStart() loop. I thought I was deleting the objects - so why the memory leak?