MQL4 memory leakage

 

Is MQL4 language still supported? There is memory leakage issue which makes me sometimes to spend many times to find where this problem is in my code. I have created smart pointer which sometimes should be converted to different interface type when it passed to class as reference.

If MQL4 language still supported please can you fix this bug.


class Assignee
{
public:
   Assignee(){}
   Assignee(const Assignee&) {}
};

class Test
{
public:
   Test()
      : _assignee(Assignee()) // Memory leak here I'm not able to use smart pointers conversions to different interface type in this case or other simple objects which should use copy constructor instead allocation object at memory and deleting it
   {}
   Assignee _assignee;
};
      
int OnInit()
  {
   Test a;
   return(INIT_SUCCEEDED);
  }




Thanks.

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
ALEKSANDR SHUKALOVICH:

Is MQL4 language still supported? There is memory leakage issue which makes me sometimes to spend many times to find where this problem is in my code. I have created smart pointer which sometimes should be converted to different interface type when it passed to class as reference.

If MQL4 language still supported please can you fix this bug.

Thanks.

MT4/MQL4 is no longer being developed for many years now. Only very critical issues get addressed.

 
   Test()
      : _assignee(Assignee()) 

This should create an anonymous Assignee on the stack. Then it creates a copy in assignee using the reference. When the constructor exits the original should be destroyed.

Apparently, this doesn't work properly in the construction list. Why are you not just using:

   Test()
      : _assignee() {}