[osg-users] ref_ptr, ptr and leaking question (quite simple)

Ariasgore ariasgore at gmx.de
Sat Jul 26 02:22:37 PDT 2008


Hello,
I have some novoice question about the use of pointers as short-time 
reference. As in the tutorial book described all objects deriving from 
osg::Referenced should be used with ref_ptr for proper use.
But even in the book and in some tutorials there are many uses of the plain 
c++ pointer without the reference use of ref_ptr.
There is where I have one question, if I develop in VisualStudio for 
instance and write some code like:

osg::Geode * g = new osg::Geode;
...
viewer.setSceneData(g);

Doesn't I have a ref count of 2 for g? Whild would result in a leak since I 
never delete the g pointer manually?

If this above is true and the programm is running as a childprocess of my 
IDE (since I have debugging and stacktracing and so on), don't I create some 
leaking beyond the lifetime of the programm? I am not quite sure if the 
memory is cleaned after finishing the programm or the whole IDE.

Thanks
Sam 



More information about the osg-users mailing list