Hi,
I am using OSG to render screenshots of a terrain model at regular intervals.
The process is growing continuously and after ~130 screenshots it has exhausted
all memory (RAM + Swap = 8GB) and gets killed by the OS.
I am guessing that some of the PagedLODs are not being freed completely after
they are no longer needed. The following minimal test case uses LODScale to
make the DatabasePager load and then discard PagedLODs instead of moving the
camera around, but it also shows symptoms of not freeing all of the memory.
How to reproduce it: (works with OSG 2.8.3, 2.9.16, 3.0.0, 3.0.1 and today's
trunk r12712)
1) Modify osgviewer.cpp:
Replace:
Code:
viewer.addEventHandler(new osgViewer::LODScaleHandler);
By:
Code:
osg::ref_ptr< osgViewer::LODScaleHandler> pLODHandler = new
osgViewer::LODScaleHandler;
pLODHandler->setKeyEventIncreaseLODScale('+');
pLODHandler->setKeyEventDecreaseLODScale('-');
viewer.addEventHandler(pLODHandler);
osg::ref_ptr< osgDB::DatabasePager> pager = viewer.getDatabasePager();
pager->setTargetMaximumNumberOfPageLOD(1);
This is to allow changing the LODScale at runtime, and to make osgviewer use as
little memory as possible.
2) Launch osgviewer with a large, paged model.
The osgviewer starts at a default LODScale = 1. On my system, osgviewer uses
267MB
3) Decrease LODScale by pressing - repeatedly
osgviewer shows more details, and as expected, it uses more memory. In my case,
2335MB at LODScale = 0.0473624.
4) Increase LODScale back to 1 by pressing + repeatedly
osgviewer shows less details, but there is no corresponding reduction in memory
usage. (It remains almost constant: 2333MB.)
Am I correct in expecting memory usage to go approximately back to the initial
267MB?
I have been trying to debug the issue and looked at
SetBasedPagedLODList::removeExpiredChildren(). In that function,
SetBasedPagedLODList::_pagedLODs.size() does decrease when LODScale increases,
so this seems correct. I also noticed childrenRemoved.size() is only 1/4 of the
decrease in SetBasedPagedLODList::_pagedLODs.size(). Am I correct in assuming
that these numbers should be the same?
Specs:
OS: Ubuntu 10.10 Maverick Meerkat, 64bit
Mem: 4GB RAM + 4GB Swap
Video: GeForce 8800 GTX, Driver: 260.19.06
OSG: 2.8.3, 2.9.16, 3.0.0, 3.0.1, today's trunk r12712
Model: 9.9G, generated with osgdem -t ../CH_WGS84/tex -d ../CH_WGS84/dem -l 9
-o model.ive --no-terrain-simplification --geocentric --cs "+proj=latlong
+ellps=WGS84 +datum=WGS84"
...
Thank you!
Cheers,
Georges
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41551#41551
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org