I've noticed that when debugging an indicator in MT4, I'm seeing a series of "delete invalid pointer" messages in the terminal's expert tab.
In the indicator, every new object that I create is specifically deleted using "delete objName", prior to testing the object variable like so:-
where the code for IsNull is as follows:-
bool CUtils::IsNull(CObject *object)
return (object==NULL || CheckPointer(object)==POINTER_INVALID);
When I run the same indicator in the terminal, there are no such errors reported in the terminal's expert tab and the indicator runs as expected.
Any ideas why there might be this inconsistency between running in the debugger, and directly using the indicator in the terminal?
The problem is you can have pointers to static objects, and if you try to delete a static object then you will obviously get errors. The correct way to delete an object is as follows.
if (CheckPointer(obj) == POINTER_DYNAMIC)
Awsome! Thanks for the heads-up with this Nicholi :)