handle memory leak and new thread for ogre