[osg-users] how to clear Vec3Array

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Thu Jul 14 10:49:11 PDT 2016


Hi Bruno,
> hello,
>
> I am doing the following experiment:
>
> osg::ref_ptr<osg::Vec3Array> array(new osg::Vec3Array);
> array->resize(300000000);
> array->clear();
>
> This does not deallocate the memory.
It is "detaching" the memory. There is no guarantee the memory is 
actually freed at this point (see std::vector)
The only safe way to "de"-allocate a std::vector is to get it out of 
scope or swap it with an empty vector.
Note that for c++11 there is also a shrink_to_fit.

Cheers
Sebastian
>
> How do I effectively deallocate the memory from the std::vector 
> encapsulated in the osg::Vec3Array?
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160714/10c7719c/attachment-0003.htm>


More information about the osg-users mailing list