Memory Problems !

zhucde

11-05-2010 08:02:11

i found two memory problems,

Problem1. PG object can no be delete completely.

see Example8:

void World::unload()
{
//[NOTE] Always remember to delete any PageLoader(s) and PagedGeometry instances to avoid memory leaks.

//Delete the PageLoader's
delete grass->getPageLoader();
delete trees->getPageLoader();
delete bushes->getPageLoader();

//Delete the PagedGeometry instances
delete grass;
delete trees;
delete bushes;

//Also delete the entities
sceneMgr->destroyEntity("Tree1");
sceneMgr->destroyEntity("Fern");
sceneMgr->destroyEntity("Plant");
sceneMgr->destroyEntity("Mushroom");
}


if you unload all PG then reload it , you will find the Memory increased then first load,
if you do it time and again, the memory will increase more and more.

so how to delete pg completely ?

Problem2:
when go through the PG scene(the more pg objects , the more obvious), the memory increase slowly,
i test a scene, with 20 pg objects,
when start , the memory is 600M, and then play a camera animation with loop,
in fourth round, the memory increased by 100M,
and the FPS Reduce doubled,
it is terrible ,
what's wrong with it ?

Fish

11-05-2010 13:37:28

Thanks for the report but I don't see the same issue here with tens of thousands of trees, hundreds of rocks, and thick grass in a 10 square-km world. My memory footprint is a pretty constant 310mB (as reported by the Windows Task Manager, which is really never a good way to determine actual memory allocations). Are you using memory leak software to detect the leaks or are you relying on the Windows Task Manager (or whatever the equivalent is in your operating system)? I use Visual Leak Detector with MSVC and it does not detect any memory leaks.

The frame rate reduction is troubling. I frankly haven't seen this issue with PG. What video card are you using?

A few suggestions:

1) Make sure you are using the latest source from the Mercurial Repository. Many many memory leaks have been detected and fixed in the latest source.

2) Open Source projects rely heavily on the users to find and fix bugs and contribute a patch back to the community. If you can even narrow it down to a specific function that's causing the problem then the PG community will be better able to help you work through the debug process.

3) If you find that you are unable to locate the source of the problem, use the latest PG source and one of the PG examples that comes with PG to provide a reproducible case. That will enable the community to help you debug.

- Fish

zhucde

11-05-2010 16:43:16

thanks for your replying, fish.

i already use the latest source code PG1.1.0 from the Mercurial Repository , my card is GF9800GT, CPU: Core2 Quad Q8200
problem1:

do you try follow code to delete a PG object:


delete trees->getPageLoader();
delete trees;


it can't release memory that it used

problem2:

i create 20 PG objects, each PG have about 4000 trees, they are distributed on the side of a road which is 10KM long,
when demo running, the camera on the beging of the road, the FPS is 30, the memory is 520M (reported by windows taskmgr),
the camera animation is from beginging of the road to end,
when the animation playing, the memory increasing.
when animation end , the camera switch to the begining and loop again,
the memory keep on increasing ,
at the fourth round, the memory increased 100M. FPS is 15.

zhucde

12-05-2010 04:04:17

i found that when does it happen.

if i go through the scene by keyboard control , no problem,
the memory increase and reduce dynamically,

but , when We entered a dense forest and after the memory increased,
then set the camera to anoter postion far from here(no go there, jump to, to a sparse area ),
the memory will not reduce,
if you continue going , the memory continue increase,

does it because the PG cache bug ?

Fish

12-05-2010 14:01:43

re: problem 1:

Yes. The difference though is that I keep the pointers to my Forests::TreeLoader3D objects in a vector and then delete them all or individually when I need to. I haven't seen any memory leaks.

re: problem 2:

You can start debugging by looking at the code in GeometryPageManager::update() starting at line 587. You'll need to figure out if your distant pages are being unloaded after the jump and if they are not being unloaded you'll need to figure out why.

-Fish

zhucde

13-05-2010 16:41:48

Thanks!

before it , i have another question: when jump to another position, can i call the reloadGeometry() to unload all page?

i test it , but the memory also increasing , i have no ideas about it .