New without Delete workinf fine
-
laweya
- Kobold
- Posts: 28
- Joined: Mon Jan 17, 2005 3:48 pm
- Location: Kenya
New without Delete workinf fine
I have been programming in c++ for a while but I'm fairly new to 3d programming. Going through Ogre's tutorials, I realised that there are objects created using "new" but are not released using "delete", I have the directx SDK on debug which really complains on memory leaks but I get none when I compile and run the tutorials, how is this possible? When I try to delete the objects, my program crashes.
-
haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
Can you be more specific about the created objects? Maybe show us the code lines.
There are methods that destroy certain data. For instance SceneManager::clearScene() implicitly deletes all SceneNodes. And most Managers delete all data they are responsible for in their destructors. All this behaviour is described in the corresponing API documentation.
There are methods that destroy certain data. For instance SceneManager::clearScene() implicitly deletes all SceneNodes. And most Managers delete all data they are responsible for in their destructors. All this behaviour is described in the corresponing API documentation.
-
laweya
- Kobold
- Posts: 28
- Joined: Mon Jan 17, 2005 3:48 pm
- Location: Kenya
Which classes get cleaned up and which ones don't?
It makes sense if you put it that way, but how do you know whether your class will be cleaned up by the code, e.g. The Lights Camera Action tutorial has instances of LightFlasherControllerFunction and LightBlinker classes and I think they get automatically cleaned up.
-
guts
- Gnoblar
- Posts: 24
- Joined: Thu Oct 28, 2004 3:18 pm
and I think it's the same with Listeners ... maybe these classes should be SharedPointers, so that it's obvious that you do not have to delete them?
PS: Sorry for all my "you could change this" topics on your forum *gg*
it's just because i'm writing my own engine, but really like ogre's design (that's why i adapted some of it in my engine
)
PS: Sorry for all my "you could change this" topics on your forum *gg*
it's just because i'm writing my own engine, but really like ogre's design (that's why i adapted some of it in my engine
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
Listeners do have to be deleted, actually - that's because you create them. The rule is that if your code performs the new, it has to perform the delete. Shared pointers are a special case.
All the 'new' entries you saw were Ogre; in places like createEntity etc. Ogre manages the destruction of those objects so the user doesn't have to worry about it. They are being delete'd inside Ogre.
All the 'new' entries you saw were Ogre; in places like createEntity etc. Ogre manages the destruction of those objects so the user doesn't have to worry about it. They are being delete'd inside Ogre.