Latest svn memory leaks on GrassLoader

MusgooDKZ

19-07-2009 09:43:23

This happens only when grass->update(); function called

{
grass = new PagedGeometry(mCamera, 30);
grass->addDetailLevel<GrassPage>(200);

//Create a GrassLoader object
grassLoader = new GrassLoader(grass);
grass->setPageLoader(grassLoader); //Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance

//Supply a height function to GrassLoader so it can calculate grass Y values
HeightFunction::initialize(mSceneMgr);
grassLoader->setHeightFunction(&HeightFunction::getTerrainHeight);

//Add some grass to the scene with GrassLoader::addLayer()
GrassLayer *l = grassLoader->addLayer("3D-Diggers/plant1sprite");

//Configure the grass layer properties (size, density, animation properties, fade settings, etc.)
l->setMinimumSize(0.3f, 0.3f);
l->setMaximumSize(0.5f, 0.5f);
l->setAnimationEnabled(true); //Enable animations
l->setSwayDistribution(7.0f); //Sway fairly unsynchronized
l->setSwayLength(0.1f); //Sway back and forth 0.5 units in length
l->setSwaySpeed(0.1f); //Sway 1/2 a cycle every second
l->setDensity(10.0f); //Relatively dense grass
l->setRenderTechnique(GRASSTECH_SPRITE);
l->setFadeTechnique(FADETECH_GROW); //Distant grass should slowly raise out of the ground when coming in range
l->setDensityMap("densitymap.png");
l->setMapBounds(TBounds(0, 0, 1400, 1400)); //(0,0)-(1500,1500) is the full boundaries of the terrain

}

{
delete grass->getPageLoader();
delete grass;
}

But i read this bug was fixed. Or i something missed ?

Fish

19-07-2009 13:13:37

No leaks here.

Usually leaks don't occur on a line with a function call like update(), they usually happen on a line with the 'new' operator. What compiler are you using? What tool are you using to detect memory leaks? Can you paste the memory leak log?

-Fish

garvek

01-08-2009 22:43:16

Actually there are mesh generated in grass->update(), so there could be allocation in there.

Fish

02-08-2009 13:53:20

That may be true. If MusgooDKZ or anyone else can reproduce the leak and provide the leak detectors stack trace I'm sure it could be fixed. VLD is not detecting leaks in PG, otherwise it would have been fixed long ago. :wink:

-Fish

skynet

26-10-2009 09:58:16

yep. you right about memory leak, but its not in grass->update()
its in unloadpage()
i fixed in this way:
1) void GrassLoader::unloadPage(PageInfo &page){}
2)void GrassPage::removeEntities()
{
std::list<SceneNode*>::iterator i;
for (i = nodeList.begin(); i != nodeList.end(); ++i){
SceneNode *node = *i;
Entity *ent=static_cast<Entity*>(node->getAttachedObject(0));
MeshManager::getSingleton().remove(ent->getMesh()->getName());
sceneMgr->destroyEntity(static_cast<Entity*>(node->getAttachedObject(0)));
sceneMgr->destroySceneNode(node->getName());
}
nodeList.clear();
}

maybe some stupid way but works great

tdev

27-03-2010 14:00:32

yep. you right about memory leak, but its not in grass->update()
its in unloadpage()
i fixed in this way:
1) void GrassLoader::unloadPage(PageInfo &page){}
2)void GrassPage::removeEntities()
{
std::list<SceneNode*>::iterator i;
for (i = nodeList.begin(); i != nodeList.end(); ++i){
SceneNode *node = *i;
Entity *ent=static_cast<Entity*>(node->getAttachedObject(0));
MeshManager::getSingleton().remove(ent->getMesh()->getName());
sceneMgr->destroyEntity(static_cast<Entity*>(node->getAttachedObject(0)));
sceneMgr->destroySceneNode(node->getName());
}
nodeList.clear();
}

maybe some stupid way but works great


thank you for finding this, i could reproduce the memory leak itself, but i see that it would be better to have it done like you patched it.

will integrate your idea into the SVN later on :)