Index: /OpenSceneGraph/trunk/include/osgDB/Registry
===================================================================
--- /OpenSceneGraph/trunk/include/osgDB/Registry (revision 10227)
+++ /OpenSceneGraph/trunk/include/osgDB/Registry (revision 10520)
@@ -419,16 +419,19 @@
           * This would typically be called once per frame by applications which are doing database paging,
           * and need to prune objects that are no longer required.
-          * Time value is time in seconds.*/
-        void updateTimeStampOfObjectsInCacheWithExternalReferences(double currentTime);
+          * The time used is taken from the FrameStamp::getReferenceTime().*/
+        void updateTimeStampOfObjectsInCacheWithExternalReferences(const osg::FrameStamp& frameStamp);
 
         /** Removed object in the cache which have a time stamp at or before the specified expiry time.
           * This would typically be called once per frame by applications which are doing database paging,
           * and need to prune objects that are no longer required, and called after the a called
-          * after the call to updateTimeStampOfObjectsInCacheWithExternalReferences(currentTime). 
-          * Note, the currentTime is not the expiryTime, one would typically set the expiry time
-          * to a fixed amount of time before currentTime, such as expiryTime = currentTime-10.0.
-          * Time value is time in seconds.*/
-        void removeExpiredObjectsInCache(double expiryTime);
-        
+          * after the call to updateTimeStampOfObjectsInCacheWithExternalReferences(frameStamp).*/
+        void removeExpiredObjectsInCache(const osg::FrameStamp& frameStamp);
+
+        /** set hint to viewer code calling removeExpiredObjectsInCache to specify how long it should give before expiring objects in Registry cache,*/
+        void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
+
+        double getExpiryDelay() const { return _expiryDelay; }
+
+
         /** Remove all objects in the cache regardless of having external references or expiry times.*/ 
         void clearObjectCache();
@@ -600,4 +603,5 @@
         FilePathList                            _libraryFilePath;
 
+        double                                  _expiryDelay;
         ObjectCache                             _objectCache;
         OpenThreads::Mutex                      _objectCacheMutex;
Index: /OpenSceneGraph/trunk/include/osgViewer/Scene
===================================================================
--- /OpenSceneGraph/trunk/include/osgViewer/Scene (revision 8633)
+++ /OpenSceneGraph/trunk/include/osgViewer/Scene (revision 10520)
@@ -40,8 +40,9 @@
         const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); }
 
-
         void setImagePager(osgDB::ImagePager* ip);
         osgDB::ImagePager* getImagePager() { return _imagePager.get(); }
         const osgDB::ImagePager* getImagePager() const { return _imagePager.get(); }
+
+        void updateSceneGraph(osg::NodeVisitor& updateVisitor);
 
 
Index: /OpenSceneGraph/trunk/src/osgDB/Registry.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgDB/Registry.cpp (revision 10356)
+++ /OpenSceneGraph/trunk/src/osgDB/Registry.cpp (revision 10520)
@@ -186,4 +186,13 @@
         if (switchOff) _buildKdTreesHint = Options::DO_NOT_BUILD_KDTREES;
         else _buildKdTreesHint = Options::BUILD_KDTREES;
+    }
+
+    const char* ptr=0;
+
+    _expiryDelay = 10.0;
+    if( (ptr = getenv("OSG_EXPIRY_DELAY")) != 0)
+    {
+        _expiryDelay = osg::asciiToDouble(ptr);
+        osg::notify(osg::INFO)<<"Registry : Expiry delay = "<<_expiryDelay<<std::endl;
     }
 
@@ -2105,5 +2114,5 @@
 }
 
-void Registry::updateTimeStampOfObjectsInCacheWithExternalReferences(double currentTime)
+void Registry::updateTimeStampOfObjectsInCacheWithExternalReferences(const osg::FrameStamp& frameStamp)
 {
     OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
@@ -2118,11 +2127,13 @@
         {
             // so update it time stamp.
-            itr->second.second = currentTime;
-        }
-    }
-}
-
-void Registry::removeExpiredObjectsInCache(double expiryTime)
-{
+            itr->second.second = frameStamp.getReferenceTime();
+        }
+    }
+}
+
+void Registry::removeExpiredObjectsInCache(const osg::FrameStamp& frameStamp)
+{
+    double expiryTime = frameStamp.getReferenceTime() - _expiryDelay;
+
     OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
 
Index: /OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp (revision 10473)
+++ /OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp (revision 10520)
@@ -909,5 +909,5 @@
     {
         _expiryDelay = osg::asciiToDouble(ptr);
-        osg::notify(osg::NOTICE)<<"Expiry delay = "<<_expiryDelay<<std::endl;
+        osg::notify(osg::NOTICE)<<"DatabasePager: Expiry delay = "<<_expiryDelay<<std::endl;
     }
 
@@ -916,5 +916,5 @@
     {
         _expiryFrames = atoi(ptr);
-        osg::notify(osg::NOTICE)<<"Expiry frames = "<<_expiryFrames<<std::endl;
+        osg::notify(osg::NOTICE)<<"DatabasePager: Expiry frames = "<<_expiryFrames<<std::endl;
     }
 
@@ -930,5 +930,5 @@
         }
             
-        osg::notify(osg::NOTICE)<<"Release delay = "<<_releaseDelay<<std::endl;
+        osg::notify(osg::NOTICE)<<"DatabasePager: Release delay = "<<_releaseDelay<<std::endl;
     }
     else
@@ -1782,12 +1782,4 @@
                               " B="<<time_b<<" avg="<<s_total_time_stage_b/s_total_iter_stage_b<<" max = "<<s_total_max_stage_b<<
                               " C="<<time_c<<" avg="<<s_total_time_stage_c/s_total_iter_stage_c<<" max = "<<s_total_max_stage_c<<std::endl;
-
-    
-    if (osgDB::Registry::instance()->getSharedStateManager()) 
-        osgDB::Registry::instance()->getSharedStateManager()->prune();
-
-    // update the Registry object cache.
-    osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(frameStamp.getReferenceTime());
-    osgDB::Registry::instance()->removeExpiredObjectsInCache(expiryTime);
 }
 
@@ -1884,14 +1876,4 @@
     osg::notify(osg::INFO)<<"_activePagedLODList.size()="<<_activePagedLODList.size()<<" overall = "<<time<<
                               " avg="<<s_total_time/s_total_iter<<" max = "<<s_total_max<<std::endl;
-     
-   
-    if (osgDB::Registry::instance()->getSharedStateManager()) 
-        osgDB::Registry::instance()->getSharedStateManager()->prune();
-
-    // update the Registry object cache.
-    osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(frameStamp.getReferenceTime());
-    osgDB::Registry::instance()->removeExpiredObjectsInCache(expiryTime);
-
-
 }
 
Index: /OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp (revision 10365)
+++ /OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp (revision 10520)
@@ -925,21 +925,14 @@
     _updateVisitor->setTraversalNumber(getFrameStamp()->getFrameNumber());
 
-    if (getSceneData())
-    {
-        _updateVisitor->setImageRequestHandler(_scene->getImagePager());
-        getSceneData()->accept(*_updateVisitor);
-    }
-    
-    if (_scene->getDatabasePager())
-    {    
-        // synchronize changes required by the DatabasePager thread to the scene graph
-        _scene->getDatabasePager()->updateSceneGraph(*_frameStamp);
-    }
-
-    if (_scene->getImagePager())
-    {    
-        // synchronize changes required by the DatabasePager thread to the scene graph
-        _scene->getImagePager()->updateSceneGraph(*_frameStamp);
-    }
+    _scene->updateSceneGraph(*_updateVisitor);
+
+    // if we have a shared state manager prune any unused entries
+    if (osgDB::Registry::instance()->getSharedStateManager())
+        osgDB::Registry::instance()->getSharedStateManager()->prune();
+
+    // update the Registry object cache.
+    osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(*getFrameStamp());
+    osgDB::Registry::instance()->removeExpiredObjectsInCache(*getFrameStamp());
+
 
     if (_updateOperations.valid())
@@ -947,5 +940,5 @@
         _updateOperations->runOperations(this);
     }
-    
+
     if (_incrementalCompileOperation.valid())
     {
Index: /OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp (revision 10365)
+++ /OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp (revision 10520)
@@ -1038,24 +1038,15 @@
     {
         Scene* scene = *sitr;
-        if (scene->getSceneData())
-        {
-            _updateVisitor->setImageRequestHandler(scene->getImagePager());
-            
-            scene->getSceneData()->accept(*_updateVisitor);
-        }
-
-        if (scene->getDatabasePager())
-        {    
-            // synchronize changes required by the DatabasePager thread to the scene graph
-            scene->getDatabasePager()->updateSceneGraph(*_frameStamp);
-        }
-
-        if (scene->getImagePager())
-        {    
-            // synchronize changes required by the DatabasePager thread to the scene graph
-            scene->getImagePager()->updateSceneGraph(*_frameStamp);
-        }
-
-    }
+        scene->updateSceneGraph(*_updateVisitor);
+    }
+
+    // if we have a shared state manager prune any unused entries
+    if (osgDB::Registry::instance()->getSharedStateManager())
+        osgDB::Registry::instance()->getSharedStateManager()->prune();
+
+    // update the Registry object cache.
+    osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(*getFrameStamp());
+    osgDB::Registry::instance()->removeExpiredObjectsInCache(*getFrameStamp());
+
 
     if (_incrementalCompileOperation.valid())
Index: /OpenSceneGraph/trunk/src/osgViewer/Scene.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgViewer/Scene.cpp (revision 8633)
+++ /OpenSceneGraph/trunk/src/osgViewer/Scene.cpp (revision 10520)
@@ -78,4 +78,29 @@
 }
 
+void Scene::updateSceneGraph(osg::NodeVisitor& updateVisitor)
+{
+    if (!_sceneData) return;
+
+    if (getSceneData())
+    {
+        updateVisitor.setImageRequestHandler(getImagePager());
+        getSceneData()->accept(updateVisitor);
+    }
+
+    if (getDatabasePager())
+    {
+        // synchronize changes required by the DatabasePager thread to the scene graph
+        getDatabasePager()->updateSceneGraph((*updateVisitor.getFrameStamp()));
+    }
+
+    if (getImagePager())
+    {
+        // synchronize changes required by the DatabasePager thread to the scene graph
+        getImagePager()->updateSceneGraph(*(updateVisitor.getFrameStamp()));
+    }
+
+
+}
+
 
 Scene* Scene::getScene(osg::Node* node)
