Delete early

If temporary objects are allocated on the heap, delete them as soon as they are no longer needed. If the life of temporary objects is longer than they are needed, then the typical RAM consumption of the application will be higher than it needs to be. Remember, however, that if a temporary object is deleted while a pointer to it is still in scope, the pointer should be set to NULL to prevent illegal access or double deletions.