I have a global pointer variable that can be called depending on conditions and not to reallocate the variable, i am using the method like, for x for example:
Yes, but you should also check for NULL before deleting. If it's not pointing anywhere, delete can lead to problems. Also, the official "NULL" for pointers is the "nullptr" keyword. It's the exact same as "p = NULL" or "p = 0", but a bit more obvious.
-1 "delete" is guaranteed to do nothing with a null-pointer.
Standard wrote:
3.7.3.2 Deallocation functions, Paragraph 3: "The value of the first argument supplied to a deallocation function may be a null pointer value; if so, and if the deallocation function is one supplied in the standard library, the call has no effect."
Try to use a debugger. For Linux - is valgrind, for windows - deleaker, or memchek, or vld. They will show where undeleted object and need to clear memory!