Use unset ($ classVariableName) to remove the instance and it will free up memory.
If the class definition should not be present at run time, then the class should be added to a separate file, and the file should be included only when required. That way you can have two different class definitions with the same class name. But having two different definitions with the same name is not the best way to go.
source share