Reputation: 77
When i read a tutorial of ogre3d, opengl or physics framework, all the objects(Window,SceneManager object) are created in heap?
are they using heap for "the object pointer destroyed but the heap object still there(outlive a object)" ?
sorry for bad English
Upvotes: 0
Views: 81
Reputation: 238361
There are many possible reasons:
It's just incidental, and unnecessary:
Because the objects were big. This is argument against using automatic objects, but not really relevant for static.
Because the initialization needed to be delayed.
The framework has chosen to use a special singleton pattern that relies on the singletons to be allocated dynamically, since the framework will delete them automatically. I know this is the case for Ogre::LogManager
for example.
Upvotes: 3