Debugging undeleted objects

 

After executing a program, it reported a  few undeleted objects of certain type.

How to find out where are these undeleted objects?

Is there a way to access the calling function stack? 

I am thinking a solution to store the calling stack at the object constructor so that I can track the various instances that are not destroyed and pinpoint where were they created.

The calling function stack looks like this:

1   void start()
2   {
3      try();
4   }
5
6   void try()
7   {
8     // calling stack at this point should be:
9     // this_file_name, start, line 3
10    // this_file_name, try, line 8
11  }
 
williamwong:

After executing a program, it reported a  few undeleted objects of certain type.

How to find out where are these undeleted objects?

Is there a way to access the calling function stack? 

I am thinking a solution to store the calling stack at the object constructor so that I can track the various instances that are not destroyed and pinpoint where were they created.

The calling function stack looks like this:

To see what objects are in use, you can access the objects window.

This should be the same for both MT4 & MT5.


There are also a number of Object functions you may find helpful.

For MT4: https://docs.mql4.com/objects

For MT5: https://www.mql5.com/en/docs/objects


Useful information.

To delete a specific object: https://www.mql5.com/en/docs/objects/objectdelete

To delete multiple objects: https://www.mql5.com/en/docs/objects/objectdeleteall


- Jack

Object Functions - MQL4 Reference
Object Functions - MQL4 Reference
  • docs.mql4.com
This is the group of functions intended for working with graphic objects relating to any specified chart. When working with objects on the current chart, a direct access is used, i.e. the existence of the specified object is pre-checked during the function call, and the error code is immediately returned in case of failure. When a function is...
 
williamwong:

Is there a way to access the calling function stack? 


I appears that your question has already been answered here:

https://www.mql5.com/en/forum/2122

 
Jack Thomas:

To see what objects are in use, you can access the objects window.

This should be the same for both MT4 & MT5.


There are also a number of Object functions you may find helpful.

For MT4: https://docs.mql4.com/objects

For MT5: https://www.mql5.com/en/docs/objects


Useful information.

To delete a specific object: https://www.mql5.com/en/docs/objects/objectdelete

To delete multiple objects: https://www.mql5.com/en/docs/objects/objectdeleteall


- Jack


Sorry I was referring to class objects not graphic objects.
 
Anthony Garot:

I appears that your question has already been answered here:

https://www.mql5.com/en/forum/2122

https://www.mql5.com/en/forum/2122

2122 was replied in 2010.9.24 on trapping the out-of-bound array index during debug mode and that the caller stack info is not stored in release compilation for safety reason.

Wonder after so many years if MQL4 has added features that allow access to caller stack so that I can add codes in the constructor to register the caller stack and track which caller is not releasing the object.

I understand the safety issue, but by just showing number of undeleted objects of certain class is not sufficient to trace the erroneous source, I need which caller is not releasing the object and this information can be displayed during debug mode to avoid the safety issue in release compilation?

Reason: