Hi carsten, I did a bit of debug and here is what i found: My pseudo code sounds like
Node = dbTreeRoot->clone SceneRoot->addChild (Node); -- memory raises about 2000K <Do stuff> For (int i=0;i<SceneRoot->getNchildren;i++) sceneRoot->subChild(0) -- memory lower about 500k Node = dbTreeRoot->clone SceneRoot->addChild (Node); -- memory raises about 2000K And so on So I am leaking 1500K at every round. (obviously this value increases as the model cloned raises in complexity). Thanks E. > -----Messaggio originale----- > Da: [EMAIL PROTECTED] [mailto:opensg-users- > [EMAIL PROTECTED] Per conto di Carsten Neumann > Inviato: venerdì 1 dicembre 2006 13.38 > A: [email protected] > Oggetto: Re: [Opensg-users] clones and deel clones memory problem. > > Hi Enrico, > > Enrico wrote: > > Hi dirk and all opensg users, > > > > i have a small question for ya: > > I keep a small library of osg::nodeptr which I never display on screen. > > I just keep 'em as a database to be cloned as I need one instance of > them > > to be displayed. > > I expect that when I call for a node->clone, the memory allocated won't > jump > > Up too much as, if I am not misunderstood, most of the display lists are > > shared. > > Node::clone just forwards to osg::cloneTree, which builds a copy of the > source tree that shares its NodeCores with the original, i.e. you get a > new set of Nodes, but the cores are the same. > > > On the contrary, everytime I select a node for cloning and add to the > scene, > > my app's memory raise as if I've deep cloned the node. > > Does this happen everytime or just the first time adding a cloned node > to the scene, i.e.: > > NodePtr sceneRoot; > NodePtr dbNode; // a node in your "database" > > NodePtr dbClone1 = dbNode->clone(); > sceneRoot->addChild(dbClone1); // first add > > // ... > > sceneRoot->subChild(dbClone1); // dbClone1 dies here. refCount == 0 > > // ... > > NodePtr dbClone2 = dbNode->clone(); // new clone of same node > sceneRoot->addChild(dbClone2); // second add > > Does the memory consumption raise again upon second add ? > > > Now here is my doubt: > > > > If I clone a node that I've never added to the scene (so I guess it's > refCP > > is still zero) > > Yes, a freshly cloned node has a ref count of zero. > > > Instead of being cloned is it deep cloned? > > No. > > Hope it helps, > Carsten > > PS: Please do not send HTML mail to mailing lists, thank you. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Opensg-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/opensg-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
