!!! undeleted objects left

 

Hello Everyone

I have this warning message, and have checked all my classes where I have created CMarketInfo class and made sure that it is deleted on Exit the program.

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 1 undeleted objects left

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 1 object of type CMarketInfo left

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 32 bytes of leaked memory

Is there any way to find where it has been created and not deleted?
 
Anil Varma:

Hello Everyone

I have this warning message, and have checked all my classes where I have created CMarketInfo class and made sure that it is deleted on Exit the program.

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 1 undeleted objects left

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 1 object of type CMarketInfo left

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 32 bytes of leaked memory

Is there any way to find where it has been created and not deleted?

you simply need to check your source code and make sure that you are doing things correctly, you could print a message to the journal everytime you create and delete then you will have a starting point.

So unless you post your code here, there is not much more anyone can say.

 
Anil Varma:

Hello Everyone

I have this warning message, and have checked all my classes where I have created CMarketInfo class and made sure that it is deleted on Exit the program.

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 1 undeleted objects left

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 1 object of type CMarketInfo left

2024.06.10 17:28:54.019 AlgoEA (XAUUSD,M15) 32 bytes of leaked memory

Is there any way to find where it has been created and not deleted?

Are you calling an instance "new" if so,  you should use "delete" in OnDeInit()

https://www.mql5.com/en/book/oop/classes_and_interfaces/classes_new_delete_pointers

MQL5 Book: Object Oriented Programming / Classes and interfaces / Dynamic creation of objects: new and delete
MQL5 Book: Object Oriented Programming / Classes and interfaces / Dynamic creation of objects: new and delete
  • www.mql5.com
So far we have only tried to create automatic objects, i.e. local variables inside OnStart . An object declared in the global context (outside...
 
Rajesh Kumar Nait #:

Are you calling an instance "new" if so,  you should use "delete" in OnDeInit()

https://www.mql5.com/en/book/oop/classes_and_interfaces/classes_new_delete_pointers

Thanks Rajesh, yes I am aware of instance as 'new' and always make sure I delete them in deconstructor() or OnDeInit().

However, it seems I have forgot to do that somewhere. I have looked at all possible places where I have created them with 'new' and all the places command is appropriately placed for deleting it.

Still this once pops up, I was wondering if there is any way to find where it could be. 

 
Paul Anscombe #:

you simply need to check your source code and make sure that you are doing things correctly, you could print a message to the journal everytime you create and delete then you will have a starting point.

So unless you post your code here, there is not much more anyone can say.

Hi Paul

There are more than 30 files with 5000+ lines of code. Do you think someone at forum will have time to look into them? On top of that can someone share his important piece of code at forum!!!

Moreover, I have said very clearly that I know why this warning is given and I do take appropriate action to delete them.

In this particular case, it seems I have forgotten to delete the class.

Was just trying to get help, if there is way to find out which file has caused this warning.

 
Anil Varma #:

Hi Paul

There are more than 30 files with 5000+ lines of code. Do you think someone at forum will have time to look into them? On top of that can someone share his important piece of code at forum!!!

Moreover, I have said very clearly that I know why this warning is given and I do take appropriate action to delete them.

In this particular case, it seems I have forgotten to delete the class.

Was just trying to get help, if there is way to find out which file has caused this warning.

I never said you should share the code, I said if you want anyone to comment further then you would need to share the code.....

I've told you how to narrow it down, 5000 lines of code is not too much to debug you will just have to get busy, there are no tools beyond what is in the editor

 

What debugging are you talking about? How many instances of CMarketInfo do you have? I think you probably only have 1 instance of this class. Just make sure you delete it when deinitializing.

 
You know what class this object belongs to, so this can't be a difficult task. Find the CMarketInfo* type pointer and check that you are calling delete on it.
 
Vladislav Boyko #:
Find the CMarketInfo* type pointer and check that you are calling delete on it

or


 
Paul Anscombe #:

I never said you should share the code, I said if you want anyone to comment further then you would need to share the code.....

I've told you how to narrow it down, 5000 lines of code is not too much to debug you will just have to get busy, there are no tools beyond what is in the editor

Thanks Paul

I think I have got a solution to find it, as load it from a single file, I can disable the load and will get error of not finding this class. I can check it from there.

You mentioning to share the code (if I need a solution) was not needed at all. I have tried this in past and most of the time it get unchecked.

'there are no tools beyond what is in the editor' is the right and good enough answer to my problem.

 
Vladislav Boyko #:

or


Thanks Vladislav

as mentioned in another reply, I will try that option and your suggestion to look for it.