Errors, bugs, questions - page 2488

 

I could be wrong of course, but it seems 2 months ago my template was working, and now when I call the CList destructor, the objects not destroyed remain in memory, code:

#property strict
#include <Arrays\List.mqh>
//+------------------------------------------------------------------+
class CData : public CObject
  {
public:
   int               x;
   double            y;
                     CData(){};
                     CData(int ival,double dval){x=ival;y=dval;}
  };
//+------------------------------------------------------------------+
template<typename T>class CDataBase
  {
private:
   CList            *mlist;
   T                *Tptr;
public:
   void CDataBase()           { mlist=new CList;                                    }
   void ~CDataBase(void)      { delete mlist;                                       }
   int ArraySize(void)        { return(mlist.Total());                              }
   T *operator[](int index)   { return(mlist.GetNodeAtIndex(index));                }
   void  AddValue (T &value)  { Tptr = new T; Tptr  = value; mlist.Add(Tptr);       }
   string TypeName()          { return(typename(T));                                }
  };
//+------------------------------------------------------------------+
void OnStart()
  {
   CDataBase<CData>*data=new CDataBase<CData>;
   int i;
   for(i=0; i<5; i++)
     {
      data.AddValue(new CData(i,i*2.0));
     }

   for(i=0; i<data.ArraySize(); i++)
     {
      Print(i," : ",data[i].x," , ",data[i].y);
     }
   Print(data.TypeName());
   delete data;
  }
//+------------------------------------------------------------------+

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 0 : 0 , 0.0

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 1 : 1 , 2.0

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 2 : 2 , 4.0

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 3 : 3 , 6.0

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 4 : 4 , 8.0

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) CData

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 5 undeleted objects left

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 5 objects of type CData left

2019.06.21 07:19:45.926 tstlist (EURUSD,H1) 280 bytes of leaked memory

MT5 build 2085
 
Igor Makanu:

I could be wrong of course, but it seems like 2 months ago my template was working, but now when I call the CList destructor, the objects that haven't been destroyed remain in memory, the code:

#property strict
#include <Arrays\List.mqh>
//+------------------------------------------------------------------+
class CData : public CObject
  {
public:
   int               x;
   double            y;
                     CData(){};
                     CData(int ival,double dval){x=ival;y=dval;}
  };
//+------------------------------------------------------------------+
template<typename T>class CDataBase
  {
private:
   CList            *mlist;
   T                Tptr;
public:
   void CDataBase()           { mlist=new CList;                                    }
   void ~CDataBase(void)      { delete mlist;                                       }
   int ArraySize(void)        { return(mlist.Total());                              }
   T operator[](int index)   { return(mlist.GetNodeAtIndex(index));                }
   void  AddValue (T &value)  { Tptr  = value; mlist.Add(Tptr);      }
   string TypeName()          { return(typename(T));                                }
  };
//+------------------------------------------------------------------+
void OnStart()
  {
   CDataBase<CData*>* data=new CDataBase<CData*>;
   int i;
   for(i=0; i<5; i++)
     {
      CData* Tmp = new CData(i,i*2.0);
      data.AddValue(Tmp);
     }

   for(i=0; i<data.ArraySize(); i++)
     {
      Print(i," : ",data[i].x," , ",data[i].y);
     }
   Print(data.TypeName());
   delete data;
  }
//+------------------------------------------------------------------+
 
fxsaber:

Yes, you're probably right, your example works correctly, somewhere I mixed up the test examples in my sources

Thank you!

 
Вероника Сорокина:
Good afternoon. Here is the situation. My mql4 Expert Advisor/Script/indicator/whatever I have written is not attached to a chart window, I want it to stay attached to a program... like, I will write a useful thing and I don't want it to be attached to new open charts all the time. Something like a service (from MT5), but you need it on MT4.

Use services

 

Is it possible to add the current code from ME to the Terminal Favourites?



Actually, I would like to have a separate "Debugging" tab where I could add code that is currently being written and tested.

Now it turns out that for a convenient work it is necessary to have a separate Terminal, where everything that doesn't concern the current projects is absent.

Then the debugging is much faster, because there is no confusion with the rest of the code in the Terminal itself.

 

Dear developers. Please clarify, is automatic repartitioning of the indicator buffers normal? By re-partitioning I mean the following: max bars in the window, for example 5000. Buffer size + rates_total are reset to 5000 when they reach 6439. The same happens when max bars in window = 10000. Reset occurs at 11439.

Because of this the indicators may crash and show incorrect data.

Build 2085. I have noticed such behavior since about 2000 builds.

 
Alexey Kozitsyn:

Dear developers. Please clarify, is automatic repartitioning of the indicator buffers normal? By re-partitioning I mean the following: max bars in the window, for example 5000. Buffer size + rates_total are reset to 5000 when they reach 6439. The same happens when max bars in window = 10000. Reset occurs at 11439.

Because of this the indicators may crash and show incorrect data.

Build 2085. I have noticed this behavior since about 2000 builds.

This behavior was originally in five.

Give an example of an indicator crash due to buffer reallocation

 
Slava:

This was the behaviour in Five from the beginning.

Give an example of indicator crash because of buffers redistribution

So you are confirming that when there is an accumulation of 1439 bars in excess, the terminal MUST reset the buffer size to the value of the max bars in the window? If YES, this should be mentioned in the documentation. As this is unforeseen behaviour.

Regarding the example. I mean custom developments that work with bar numbers. I.e. I memorized bar number 6438 and after 2 minutes (M1 TF) buffers were redistributed and I got out of the array. Now it is clear that this is "standard" behaviour. Please update the documentation.

 

Error during execution:

class A { public:
        virtual void f( int = 0 ) { Print( 1 ); }
};
class B : public A { public:
        virtual void f( int     ) { Print( 2 ); }
};
void OnStart()
{
        B b;
        b.f();
}

Result : 1

Expected: 2 or (as in C++) - compilation error

 
Alexey Kozitsyn:

Please update the documentation.

Where does the documentation need to be updated?

The unambiguous identifier of a bar has always been the bar time, not the bar number.

If someone called ChartSetSymbolPeriod to your chart, you would easily catch a change in the number of bars. Surprise?

By the way, there is parameter rates_total in OnCalculate

Reason: