<div dir="ltr">Hi, Igor,<div><br><div>I got interested in this problem and checked your code by converting it to pure osgViewer. Here are my observations:</div><div><br></div><div>I believe you do have circular reference. Your class Scene is a callback. So RootNode points to callback but Scene callback points to RootNode. Hence circular ref.</div><div>However, this does not explain increased ref count of your geometries. But I believe this issue can be explained by by lazy clearing of render bins. RenderBins are not <br></div><div>cleared after Draw but before next frame Draw. So after your Update, your geometry is Culled/Drawn and lands in RenderLeaves of RenderBin. This RenderBin is used to draw visible geometries but its not cleared after Draw. Its cleared later, ie on next Cull/Draw traversal when RenderLeaves container cleared before it gets filled again. So on next Update you will notice increased ref count because its also added to RenderLeaves container. But the next Cull/Draw will clear RenderLeaves and your geometry will be finally released. Here is your modified test applet code ported to vanilla osgViewer and modified to use observer_ptr instead of ref_ptr for RootNode. I have put breakpoint in MyGeometry Destructor to see the call stack and the call where the geometry is actually released and that way I found the explanation.</div><div><br></div><div>Cheers, hth,</div><div>Wojtek Lewandowski </div></div></div><br><div class="gmail_quote"><div dir="ltr">czw., 12 lip 2018 o 21:49 Igor Spiridonov <<a href="mailto:igwasm@rambler.ru" target="_blank">igwasm@rambler.ru</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here is simple project which reproduces this issue - RefCountTest (<a href="https://bitbucket.org/OmegaDoom/osgrefcounttest" rel="noreferrer" target="_blank">https://bitbucket.org/OmegaDoom/osgrefcounttest</a>)<br>
<br>
It's a visual studio project with qt and osg. Not sure you are using windows but the main code in scene.cpp. ref count checks inside "Scene::operator()(osg::Node* node, osg::NodeVisitor* nv)"<br>
<br>
I expect both checks to return 1 but first one returns 2 as I explained earlier.<br>
<br>
I suppose it's the cause of memleak. I use osg 3.2.<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=74334#74334" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=74334#74334</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div>