<div dir="ltr"><br><br>On Monday, 9 December 2019 19:57:27 UTC, Greg D  wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><div>My quick fix is to clear the cache on the first render (and call clear thereafter).  OpenFlight files open and render fine now.  Is this a safe fix?</div><div><br></div><div><div>void ViewerBase::frame(double simulationTime)</div><div>{</div><div>    ....</div><div><span style="white-space:pre">  </span>osgDB::Registry::instance()-><wbr>clearObjectCache();  // ADDED TO CLEAR CACHE AFTER RENDER SINCE IT BECOMES CORRUPTED</div><div>}</div></div><div><br></div></div></blockquote><div><br></div><div>Adding this line to ViewerBase is a point of information about the problem rather than a fix.  FYI, you can override Viewer::frame() by just subclassing Viewer there is no need to modify the OSG itself.  You can also call the clear after the frame() in your own frame loop.  However, all of these clearObjectCache() changes are hacks around a different problem.</div><div><br></div><div>From your previous post that the change to OpenFlight's use of local cache vs ObjectCache indicates to me that the memory optimization of unrefering the osg::Image after the image data has been applied to the Textures texture object.  If an Texture is in the cache and could be reused *and* the texture object data is released between the first use but before that Texture is later reused.</div><div><br></div><div>The potential fixes are :</div><div><br></div><div>    Nt enable Texture::UnrefImageAfterApply  - this is set to true by the osgUtil::Optimizer's TextureVisitor.  Is you app call the Optimizer on loaded databases?<br></div><div>    Don't delete the graphics contexts, instead just close the window and reopen it when you need it.</div><div>    Don't enable the object cache usage.</div><div><br></div><div>A fix at the OSG would be for the OjbectCache to automatically detect the usage case where a Texture is in the case, it's been compiled and the image unreferred, the context deleted, then the Texture requested from the cache.   The place to do this would probably be ObjectCache::releaseGLObjects(osg::State* state).  It'd need to dynamic_cast<Texture> the Objects in the cache to find the textures then remove the Texture from the cache if it's got UnrefImageAfter enabled and no osg::Image still attached to it.</div><div><br></div><div>Robert.<br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:osg-users+unsubscribe@googlegroups.com">osg-users+unsubscribe@googlegroups.com</a>.<br />
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/osg-users/d726cd31-ce28-43ce-814c-1e293da836b8%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/osg-users/d726cd31-ce28-43ce-814c-1e293da836b8%40googlegroups.com</a>.<br />