Access to all Maya objects (curves, surfaces, DAG nodes, dependency graph nodes, lights, shaders, textures, etc.) is done through a handle object called an MObject. This handle provides a few simple methods to help determine the object type (see the MObject class documentation for a complete description). The MObject destructor does not delete the Maya object that it references—calling the destructor only deletes the handle object, thereby maintaining ownership.

IMPORTANT:You should never keep a pointer to an MObject between "runs" of the plug-in.

Instead you may want to use an MObjectHandle since this object contains information on the validity of the MObject.