Debugging undelete object - page 2

 
mql5:

use create/destroy function to count objects, something like this:

class CFoo;

int ExtFooCount=0;    // global variable

CFoo *CreateFoo() { ExtFooCount++; return(new CFoo);  }
void DestroyFoo(CFoo *foo) { if(ExtFooCount>0) ExtFooCount--; delete foo; }

class CCntPrint
  {

public:
   ~CCntPrint()
     {
      if(ExtFooCount) Print(ExtFooCount," leaked of CFoo");
      ...
     }
  };
CCntPrint ExtCountsPrinter;   // global variable




Are you refering to embed the counting in the class constructor and destructor?  This could be a workaround but quite a messy solution, I have many classes to add this kind of counter and for each class I need to maintain a different global variables.

Btw, I still prefer a system variable like _Period, _Symbol, give me a _UndeleteObjects that shows the current objects created.  I can use it to display in my debug window to trap which piece of code is not releasing the objects. 

 

Unfortunately,there will be no changes in the near future. But we have considered your proposal and put into our development plan the following:

Upon completion of MQL application debugging there will be a full report on lost (remaining in memory) objects in form of a short list (type and quantity) and in form of a long list, containing information about the 'new' operator that has created the object (filename, row, column and serial number of the call for the 'new').



 

How about a quick one to show the count of dynamic objects created in a system variable like _CountUndeletedObjects?  In this way, I can check in debugger during function entry and exit whether the objects are released properly.