SceneNode::setPosition and memory allocation

sjcomp

01-03-2006 18:36:47

I had an interesting problem. In my application I have created a node and attached a mesh to it. When I changed the node position before rendring (in frameStarted()), applicaton would allocate more and more memory. These were not memory leaks, because the memory was properly released (it could take a while for application to exit, though). I resolved this by calling the same code after the rendered frame (in frameEnded()). Any ideas why this might be happening?

This how I moved the node

pNode->setPosition(pNode->getPosition()+Ogre::Vector3::UNIT_Y);


I am not using ExampleApplication framework and I could not reproduce this problem with the ExampleApplication for demonstration.
CVS HEAD was used.

tuan kuranes

01-03-2006 18:39:22

is it PLSM2 only or it happens also Ogre standard Scene Manager ?

sjcomp

01-03-2006 19:23:27

is it PLSM2 only or it happens also Ogre standard Scene Manager ?
It does not happen with ST_GENERIC.

tuan kuranes

01-03-2006 19:40:34

Did test here and cannot reproduce that either. You'll have to find a way to reproduce the bug in demo...

sjcomp

02-03-2006 16:39:04

Thanks. If I will be able to do so, I will post it here.

sjcomp

07-03-2006 21:52:28

It turned out that the problem did not go away. I have a set of objects I am moving in the scene. The movement causes continious memory allocation. If I have only one object I have no problems. This is why it is hard to pinpoint what is going on. This does not happen with generic scene manager. Is there a way to see what objects were allocated in between rendring of two frames?

CrxGames

07-03-2006 22:18:02

I have the exact same problem, moving my character around ingame it allocates a LOT of memory every second that it's moving, with the SDK.

tuan kuranes

08-03-2006 07:44:56

debug and release ?
did you try debug, but removing the _VISITBILITY_DEBUG in plugin project settings ?

CrxGames

08-03-2006 21:41:04

It happens in release, and the memory usage gets huge, making the game unplayable in the long run.

Not sure how to explain it, I call this function in framestarted with some key checking stuff in it, if W or S are hit the node moves and memory usage goes up.

sjcomp

09-03-2006 16:34:53

_VISITBILITYDEBUG did not solve the problem.

tuan kuranes

09-03-2006 19:18:43

I still cannot reproduce the problem in demo code.
I add node and move them but that doesn't end in memory consumption...

I really need reproducable steps ind demo to help there, sorry...

perhaps if you can you post "node movement code" that cause that ?

sjcomp

09-03-2006 21:27:36

I am using Newton. I create a newton body and apply a force to it. If I am loading configuration file with a terrain, memory allocated for the process is growing. If no terrain is loaded (Default=none) or if I am using generic scene manger there is no problem. If I do not apply any force to the newton body there is no memory allocation. Newton body and applied forces have nothing to do with the PLSM2 or Ogre.

I could think that it is newton problem, but it does work with the generic scene manager and OctreeSceneManager... I also had this problem with having a SceneNode move, though I can not reproduce the problem right now. Every time I debug the issue, I arrive to a different conclusion :(.

CrxGames

11-03-2006 17:44:17

Wait, it appears it only happens to me when I use translate, not setPosition

sjcomp

13-03-2006 16:53:36

Wait, it appears it only happens to me when I use translate, not setPosition

If you use

pNode->setPosition(pNode->getPosition()+translation)

instead of translation, does it solve the problem?

CrxGames

13-03-2006 17:12:58

actually no, but it slightly reduces the amount 'leaked'

bool updateListener::onUpdate(Ogre::Real elapsedTime, Ogre::InputReader *input, emo::emoTerrainManager tMgr)
{
Ogre::Vector3 W = Ogre::Vector3(0, 0, -375 * elapsedTime);
Ogre::Vector3 S = Ogre::Vector3(0, 0, 375 * elapsedTime);

if (input->isKeyDown (KC_W))
{
control->setPosition(control->getPosition() + (control->getOrientation() * W)); //issue
// control->translate((control->getOrientation() * W)); //issue
}
if (input->isKeyDown (KC_S))
{
control->setPosition(control->getPosition() + (control->getOrientation() * S)); //issue
//control->translate((control->getOrientation() * S)); //issue
}
if (input->isKeyDown (KC_A))
{
control->yaw(Ogre::Radian (2 * elapsedTime));
}
if (input->isKeyDown (KC_D))
{
control->yaw(Ogre::Radian (-2 * elapsedTime));
}

Ogre::Vector3 pos = control->getWorldPosition();

pos.y = tMgr.getHeightAt(pos.x, pos.z);

control->setPosition(pos);

return true;
}


It only does it on the lines marked issue, so it might have someting to do with Ogre::InputReader, hell this issue might be fixed by now since the last prebuilt SDK was OGRE 1.0.5.

tuan kuranes

14-03-2006 16:21:11

It does not happen with ST_GENERIC.

Did you check with ST_EXTERIOR (terrain scene manager ?)

tuan kuranes

14-03-2006 16:59:40

I may have an Idea.


Try to reduce Octree Depth

int depth = 8;
myscenemanager->setOption("Depth", &depth );


After setworldgeometry() call.

CrxGames

14-03-2006 17:28:19

I may have an Idea.


Try to reduce Octree Depth

int depth = 8;
myscenemanager->setOption("Depth", &depth );


After setworldgeometry() call.


If I do that my terrain and objects completely dissapear when I move forward past a certain spot, and no it doesn't help.

tuan kuranes

14-03-2006 17:43:08

If I do that my terrain and objects completely dissapear when I move forward past a certain spot, and no it doesn't help.
That may be a bug...

it doesn't help.
Try with lower values, 8 may still be high.

CrxGames

14-03-2006 17:54:40

If I do that my terrain and objects completely dissapear when I move forward past a certain spot, and no it doesn't help.
That may be a bug...

it doesn't help.
Try with lower values, 8 may still be high.


The amount that it 'leaks' decreases but doesn't stop, did I mention it only happens after I get input for some reason?

tuan kuranes

15-03-2006 20:23:45

You can download a new SDK and CVS version now use a memory pool for Octree, so if it's octree related, it should resolve the bug.

sjcomp

21-03-2006 18:57:27

maybe you can post the complete code? I will try to compile it with the CVS HEAD.

tuan kuranes

22-03-2006 08:10:46

@sjcomp : it's in latest SDK or CVS. (SDK is now CVS snapshot, and CVS is Ogre branch v1-2 compatible til Dagon is released. )