There is no problem... there is an error. I also don't understand why you're trying to pull the explanation out of your head. The default Print has the following signature:
And it can also clash with other functions (if needed)
The Print signature is out of range of MQL5 language. If MQL5 prohibits Print overloading at all, it won't be a bug.
I hope this "bug" does not prevent you from creating TS and does not require writing crutches.
I measured the performance of the Tester. To do this, I opened and closed a position on each tick. I measured the time of execution of 100 ticks. I ran it through 100 000 ticks. I measured a total of 1000 ticks. I got this chart
There are spikes of slowing down at almost equal distances between them. I measured it in the Optimization mode. If I ignore those spikes the tester's performance varies by 25% instead of the constant value. Maybe it's Windows speed metering tricks again.
SZZ The same code I ran on MT4
On average it takes MT4 Tester 1.5-2 times less time to process one tick than MT5.
... On every tick opened and closed a position. <br / translate="no"> On average it takes MT4-Tester 1.5-2 times less time to process one tick than MT5.
void f()
{
for ( int i = 0;; )
{
Print( i );
int i = 5; //Warning: declaration of 'i' hides local declarationPrint( i );
break;
}
}
void For( int i = 0 )
{
Print( i );
int i = 5; //Error: redefinition of formal parameter 'i'Print( i );
}
What's the fundamental difference? In C++, for example, there is an error in both cases
I'm asking for help from knowledgeable people to understand the issue of pointers to class instances. I do not understand it.
Here is an example of the script:
class A
{
public :
A() { Print("Start"); };
~A() {
Print("End");
Print(EnumToString(CheckPointer(GetPointer(this))));
if (CheckPointer(GetPointer(this))!=POINTER_DYNAMIC)
deleteGetPointer(this);};
};
A a;
voidOnStart()
{
}
2018.09.2321:46:42.960 Test_CheckPointer (EURUSD,M1) Start
2018.09.2321:46:42.961 Test_CheckPointer (EURUSD,M1) 1 undeleted objects left
2018.09.2321:46:42.961 Test_CheckPointer (EURUSD,M1) 1 object of type A left
2018.09.2321:46:42.961 Test_CheckPointer (EURUSD,M1) 32 bytes of leaked memory
i.e. the destructor is not even started and therefore memory is not freed.
But if an instance of a class is declared as:
A a= new A;
the constructor is launched twice, the destructor - once, but memory is not freed and we have thePOINTER_AUTOMATIC object pointer type, although it was intended to bePOINTER_DYNAMIC
2018.09.2321:54:24.844 Test_CheckPointer (EURUSD,M1) Start
2018.09.2321:54:24.844 Test_CheckPointer (EURUSD,M1) Start
2018.09.2321:54:24.844 Test_CheckPointer (EURUSD,M1) End
2018.09.2321:54:24.844 Test_CheckPointer (EURUSD,M1) POINTER_AUTOMATIC2018.09.2321:54:24.844 Test_CheckPointer (EURUSD,M1) 1 undeleted objects left
2018.09.2321:54:24.845 Test_CheckPointer (EURUSD,M1) 1 object of type A left
2018.09.2321:54:24.845 Test_CheckPointer (EURUSD,M1) 32 bytes of leaked memory
How to always execute the destructor and correctly execute delete
There is no problem... there is an error. I also don't understand why you're trying to pull the explanation out of your head. The default Print has the following signature:
And it can also clash with other functions (if needed)
The Print signature is out of range of MQL5 language. If MQL5 prohibits Print overloading at all, it won't be a bug.
I hope this "bug" does not prevent you from creating TS and does not require writing crutches.
I measured the performance of the Tester. To do this, I opened and closed a position on each tick. I measured the time of execution of 100 ticks. I ran it through 100 000 ticks. I measured a total of 1000 ticks. I got this chart
There are spikes of slowing down at almost equal distances between them. I measured it in the Optimization mode. If I ignore those spikes the tester's performance varies by 25% instead of the constant value. Maybe it's Windows speed metering tricks again.
SZZ The same code I ran on MT4
On average it takes MT4 Tester 1.5-2 times less time to process one tick than MT5.
Possibly surges through the use of a genetic optimisation algorithm.
On average it takes MT4-Tester 1.5-2 times less time to process one tick than MT5.
Possibly surges through the use of a genetic optimisation algorithm.
No GA. Optimisation from two passes on one Agent.
And this is already pure manipulation and misleading.
The source code is in place.
In one case a warning, in the other an error
What's the fundamental difference? In C++, for example, there is an error in both cases
I'm asking for help from knowledgeable people to understand the issue of pointers to class instances. I do not understand it.
Here is an example of the script:
When executing it we have, as expected:
if an instance of a class is declared as:
A *a= new A;then on execution we have:
i.e. the destructor is not even started and therefore memory is not freed.
But if an instance of a class is declared as:
A a= new A;the constructor is launched twice, the destructor - once, but memory is not freed and we have thePOINTER_AUTOMATIC object pointer type, although it was intended to bePOINTER_DYNAMIC
How to always execute the destructor and correctly execute delete
Как добиться всегда выполнения деструктора и правильного выполнения delete.
See from C++ the topic of smart pointers and adapt for MQL(https://habr.com/post/140222/).
Maybe there's something in kodobase...
See from C++ the topic of smart pointers and adapt for MQL(https://habr.com/post/140222/).
Maybe there's something in kodobase...
thanks, but didn't see any answers to my questions there.
I don't understand why the destructor is not called whenA *a= new A;
Thank you, but I didn't see any answers to my questions there.
I don't understand why the destructor is not called whenA *a= new A;
Result:
1:POINTER_AUTOMATIC
1:POINTER_DYNAMIC
2:POINTER_DYNAMIC
2:POINTER_AUTOMATIC
Thank you, but I didn't see any answers to my questions there.
I don't understand why destructor is not called whenA *a= new A;
Create with new and delete with delete