Hi Praveena,
On 27/07/12 23:30 , Praveena Sara wrote:
> I'm drawing lines between two markers in osgart. So whenever they are moved,
> the lines are updated each time.
>...
> My program crashes after it is run for a several seconds/minutes. I found out
> that the
> following lines cause the issue (commenting those can avoid it)
>...
> I assume it is due to a memory leak, eventhough I use points->clear() at the
> end.
>
> Code:
> class CallBackClass: public osg::NodeCallback{
>
> private:
> osg::ref_ptr<osg::Vec3Array> points;
> osg::ref_ptr<osg::Geometry> beam;
>
> public:
> CallBackClass::CallBackClass(){
> points = new osg::Vec3Array;
> beam = new osg::Geometry;
> }
>
> void CallBackClass::operator(){
> // osg::Vec3 StartPoint,
> // osg::Vec3 EndPoint
>
> points->push_back(StartPoint);
> points->push_back(EndPoint);
> beam->setVertexArray(points.get());
> beam->setColorArray(color.get());
> beam->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
> beam->addPrimitiveSet(new osg::DrawArrays(GL_LINES,0,2));
> points->clear();
> }
> }
It looks very odd that you're first adding the two points and then immediately
remove them
afterwards. The primitive set that you're adding is still relying that those
two points
are there!
By the way, you do realise that you're adding a new DrawArrays on every
'operator()' call?
Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org