Hi Joel, The OSG usages referenced counting of objects that ensures that cleans up for itself. However, it does require you to use ref_ptr<> for any global pointers to the scene graph objects, as C pointers aren't able to automatically do the ref counting.
There has been lots discussed about memory management, ref counting and ref_ptr<> on the osg-users list/forum over the years, and it's also discussed in the OSG books so I'd recommend you go look up the topic. Robert. On Thu, Sep 22, 2011 at 10:30 AM, Joel Graff <[email protected]> wrote: > Hi, > > I'm running into a mysterious memory issue with the RemoveChild() function, > and I'm not sure where the error exactly lies (whether it's with OSG or > something I've done)... > > Anyway, the app I've written is driven by a console-level interface. It's > broken into two core classes: Console and Scene. Console parses input from > the console and calls the appropriate functions (by a string / function > pointer map) in Scene. Of course, Console maintains a pointer to the > instance of Scene. > > The problem occurs when I try to load a previously saved file. Specifically, > my scene graph has a top root node ( named "root"), with it's immediate child > the "project_root" node. All other nodes are subordinate to project_root. > > My saving mechanism, then, serializes "project_root" and it's children - > "root" is, itself excluded. > > It would seem, then, that loading would simply be a matter of loading the > previously saved file, destroying all children under root, then adding the > loaded group and it's children as a child of root. In fact, this works fine. > > What's throwing me is that the call to _root->removeChild() appears to > overwrite most of the Scene class instance and destroys my Scene* pointer in > Console (pointing it to 0xfeeefeee). > > I have no idea what's causing this - poor memory management on my part? I'll > happily post code if needed... > > Thank you! > > Cheers, > Joel > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=42934#42934 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

