Hi Robert, Here the time frame where i have a problem: a thread A do osg::Object* obj = osgDB::readObjectFile(url); the obj is returned from cache, and later i do
a the same time the main thread execute (just after the execution of the readObject of the thread A) osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(*getFrameStamp()); osgDB::Registry::instance()->removeExpiredObjectsInCache(*getFrameStamp()); because obj is not reference counted yet, the main thread will see the reference count to 1, then it will not update the frame stamp of the data in cache. If the data is valid to expire, then the data will be deleted while in another thread i will reference it. That's the behavior i have in my application, i understand that if i ref_ptr the data in cache forever everything will be fine (because the time stamp will be updated ...). Cheers, Cedric - +33 659 598 614 Cedric Pinson mailto:[email protected] http://www.plopbyte.net On Tue, 2009-09-08 at 06:34 +0100, Robert Osfield wrote: > Hi Cedric, > > I wouldn't have though my change will have introduced a new threading > issue, perhaps just revealed on old one though. I've just done a > review of the Registry methods that access the cache and I can't find > any points where the Registr::_objectCacheMutex isn't locked before > access of the Registr::_objectCache map. > > This leaves me without a lead w.r.t looking at how the viewer might be > reading from the cache at the same time as it's being cleared. Could > you explain at what point this problem is occurring? > > Robert. > > On Mon, Sep 7, 2009 at 6:18 PM, Cedric Pinson<[email protected]> > wrote: > > Hi Robert, > > > > I had a crash in my application because i use osgDB::readFilexxxx from > > another thread than Viewer. > > In fact there is a short window if the cache is cleared while another > > thread reference the data. > > osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(*getFrameStamp()); > > osgDB::Registry::instance()->removeExpiredObjectsInCache(*getFrameStamp()); > > > > Here the revision and the diff code on the link. > > [svn r10520] Moved the updating and expiry of the Registry object cache > > from DatabasePager into osgViewer::Viewer/CompositeViewer > > http://hg.plopbyte.net/osg-trunk/diff/85a3231b7b00/src/osgViewer/Viewer.cpp > > > > > > It's possible i had the problem before this commit, but i would just > > want to put it on the mailing list if other people have similar problem. > > > > For explanation this how i use it: > > for each player (10) > > I fetch the url http://a.com/node.osg -> the first time it will be > > downloaded then for other i will use the value in the cache registry > > (throw the readNodeFile). > > I clone the data in cache because i have to setup specific stuff by > > player so i can't modify the original data fetched in cache, i want to > > keep the data in cache clean. > > > > > > The reference count is 1 except when i get the pointer and clone it, so > > the > > osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(*getFrameStamp()); > > does not update the timestamp and finally will delete the value in > > cache. > > > > I changed the expiry time to a very big value, but i would prefer to > > have a consistent fix. I guess i should keep the pointer on a kind of > > registry in my application. > > > > > > Cheers, > > Cedric > > > > - > > +33 659 598 614 Cedric Pinson mailto:[email protected] > > http://www.plopbyte.net > > > > > > _______________________________________________ > > osg-users mailing list > > [email protected] > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > > >
signature.asc
Description: This is a digitally signed message part
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

