<div dir="ltr"><div>Hi Hui,</div><div><br></div><div><br></div>On Tuesday, 26 May 2020 10:36:18 UTC+1, Hui Li wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><br><div>The codes looks like this: </div><div>```</div><div><div>root = GroupOfSwitch(); </div><div>viewer->setSceneData(root);</div><div>while (!viewer->done()) {</div><div> root->removeChild(0); // Remove the point cloud </div><div> pc = sensor.Capture(); // Get the point cloud</div><div> geo = CreateGeometryNode(pc);</div><div> root->addChild(geo); // Add the pointcloud </div><div> viewer->frame();</div><div>}</div></div><br></div></blockquote><div><br></div><div>In "principle" this shouldn't cause unbounded memory growth but as you don't provide any details about the CreateGeometryNode() there is no way for use know what is going on there. It could be that your leak it right there in that function call, or else where somewhere in your application.</div><div><br></div><div>While I can't comment about the details of your implementation the approach of removing, creating and adding new nodes and associated data each frame is really, really inefficient.</div><div><br></div><div>As much as possible you should try to reuse data. For a point cloud application where the data is dynamic I would personally allocate a fixed number of Geometry nodes with fixed Vec3Array's within them and single DrawArray primitive set. I'd allocate the Vec3Array to it's full size right up front and next change it's size. The DrawArrays has a count value that you can set to specify how many vertices in the array need to be rendered and needn't be the whole length of the Vec3Aray.</div><div><br></div><div>With really large datasets I would chunk the data so rather one big osg::Geometry, I'd have say 10,000 vertices in each osg::Geometry. I would also use VertexBufferObjects and avoid using DisplayLists.</div><div><br></div><div>Do this all correctly and you should get a good performance and no memory growth.</div><div><br></div><div>Robert.<br></div><div> </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/1d7f0fab-ad05-4c49-a37e-b09f6179dd0d%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/osg-users/1d7f0fab-ad05-4c49-a37e-b09f6179dd0d%40googlegroups.com</a>.<br />