OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgUtil::IntersectionVisitor eats all the memory


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Trajce Nikolov NICK
Guest





PostPosted: Tue Jan 09, 2018 12:15 pm    Post subject:
osgUtil::IntersectionVisitor eats all the memory
Reply with quote

hi Robert, Community,

I have the following code in a loop against very large quadtree based database. And this code is eating all the memory, progressively and then the system kills it . Any clue?


Thanks a lot


osg::ref_ptr<osgUtil::LineSegmentIntersector> picker;
osg::ref_ptr<osgUtil::IntersectionVisitor> iv;


osg::Vec3d getHOT(const osg::Vec3d& position, osgViewer::CompositeViewer& viewer, osg::Vec3& normal, bool& valid)
{
    osg::Vec3d result;


osg::EllipsoidModel em;
osg::Vec3d up = em.computeLocalUpVector(position.x(), position.y(), position.z());
up.normalize();


osg::Vec3d s = position + up * 100;
    osg::Vec3d e = osg::Vec3d(0, 0, 0);    


    if (viewer.getView(0)->getSceneData())
    {
#if 1
if (!picker.valid())
{
picker = new osgUtil::LineSegmentIntersector(s,e);
iv = new  MyIntersectionVisitor(RANGE);
}
picker->setStart(s);
picker->setEnd(e);
picker->getIntersections().clear();

iv->setIntersector(picker);
iv->reset();
iv->setUseKdTreeWhenAvailable(false);
//iv->setLODSelectionMode(osgUtil::IntersectionVisitor::USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION);

viewer.getView(0)->getSceneData()->accept(*iv);


if (picker->containsIntersections())
{
osgUtil::LineSegmentIntersector::Intersections           hitList = picker->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator hit = hitList.begin();


result = hit->getWorldIntersectPoint();
normal = hit->getWorldIntersectNormal();
valid = true;


return result;
}
#endif
    }
valid = false;


    return result;
}


--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11923

PostPosted: Tue Jan 09, 2018 12:26 pm    Post subject:
osgUtil::IntersectionVisitor eats all the memory
Reply with quote

Hi Nick,

This is really something you'd want to use a debug for - just run it
and break the app before anything untoward happens.

The code itself looks quite benign on a first reading, the only thing
I can think of that might cause a memory issue would be if your scene
graph had a circular reference in it so the traversal ends up in an
infinite loop.

Robert

On 9 January 2018 at 12:12, Trajce Nikolov NICK
<> wrote:
Quote:
hi Robert, Community,

I have the following code in a loop against very large quadtree based
database. And this code is eating all the memory, progressively and then the
system kills it . Any clue?

Thanks a lot

osg::ref_ptr<osgUtil::LineSegmentIntersector> picker;
osg::ref_ptr<osgUtil::IntersectionVisitor> iv;

osg::Vec3d getHOT(const osg::Vec3d& position, osgViewer::CompositeViewer&
viewer, osg::Vec3& normal, bool& valid)
{
osg::Vec3d result;

osg::EllipsoidModel em;
osg::Vec3d up = em.computeLocalUpVector(position.x(), position.y(),
position.z());
up.normalize();

osg::Vec3d s = position + up * 100;
osg::Vec3d e = osg::Vec3d(0, 0, 0);

if (viewer.getView(0)->getSceneData())
{
#if 1
if (!picker.valid())
{
picker = new osgUtil::LineSegmentIntersector(s,e);
iv = new MyIntersectionVisitor(RANGE);
}
picker->setStart(s);
picker->setEnd(e);
picker->getIntersections().clear();
iv->setIntersector(picker);
iv->reset();
iv->setUseKdTreeWhenAvailable(false);
//iv->setLODSelectionMode(osgUtil::IntersectionVisitor::USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION);
viewer.getView(0)->getSceneData()->accept(*iv);

if (picker->containsIntersections())
{
osgUtil::LineSegmentIntersector::Intersections hitList =
picker->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator hit =
hitList.begin();

result = hit->getWorldIntersectPoint();
normal = hit->getWorldIntersectNormal();
valid = true;

return result;
}
#endif
}
valid = false;

return result;
}

--
trajce nikolov nick





------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Tue Jan 09, 2018 12:34 pm    Post subject:
osgUtil::IntersectionVisitor eats all the memory
Reply with quote

Thanks Robert,

no circular reference since I am displaying that database in the viewer nicely. Here is the struct (a bit odd but it is as is):


Group
|
PagedLOD PagedLOD PagedLOD .... dozen of these
|
Quadtree (similar to VPB generated subtiles)


I was thinking the visitor is reading all of these by reading all of these PagedLODs without taking the account the range from the eyepoint. So while debuging I tried this:


struct MyIntersectionVisitor : public osgUtil::IntersectionVisitor
{
MyIntersectionVisitor(float range)
: IntersectionVisitor()
, _range(range)
{
}


virtual void apply(osg::PagedLOD& plod)
{
if (getDistanceFromEyePoint(plod.getCenter(), true) < _range)
{
osgUtil::IntersectionVisitor::apply(plod);
}
}


protected:
float _range;
};



but no luck. Is there a way to  flush all the pending and loaded nodes from the DatabasePager?


On Tue, Jan 9, 2018 at 1:23 PM, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi Nick,

This is really something you'd want to use a debug for - just run it
and break the app before anything untoward happens.

The code itself looks quite benign on a first reading, the only thing
I can think of that might cause a memory issue would be if your scene
graph had a circular reference in it so the traversal ends up in an
infinite loop.

Robert

On 9 January 2018 at 12:12, Trajce Nikolov NICK
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
hi Robert, Community,

I have the following code in a loop against very large quadtree based
database. And this code is eating all the memory, progressively and then the
system kills it . Any clue?

Thanks a lot

osg::ref_ptr<osgUtil::LineSegmentIntersector> picker;
osg::ref_ptr<osgUtil::IntersectionVisitor> iv;

osg::Vec3d getHOT(const osg::Vec3d& position, osgViewer::CompositeViewer&
viewer, osg::Vec3& normal, bool& valid)
{
     osg::Vec3d result;

osg::EllipsoidModel em;
osg::Vec3d up = em.computeLocalUpVector(position.x(), position.y(),
position.z());
up.normalize();

osg::Vec3d s = position + up * 100;
     osg::Vec3d e = osg::Vec3d(0, 0, 0);

     if (viewer.getView(0)->getSceneData())
     {
#if 1
if (!picker.valid())
{
picker = new osgUtil::LineSegmentIntersector(s,e);
iv = new  MyIntersectionVisitor(RANGE);
}
picker->setStart(s);
picker->setEnd(e);
picker->getIntersections().clear();
iv->setIntersector(picker);
iv->reset();
iv->setUseKdTreeWhenAvailable(false);
//iv->setLODSelectionMode(osgUtil::IntersectionVisitor::USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION);
viewer.getView(0)->getSceneData()->accept(*iv);

if (picker->containsIntersections())
{
osgUtil::LineSegmentIntersector::Intersections           hitList =
picker->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator hit =
hitList.begin();

result = hit->getWorldIntersectPoint();
normal = hit->getWorldIntersectNormal();
valid = true;

return result;
}
#endif
     }
valid = false;

     return result;
}

--
trajce nikolov nick



Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11923

PostPosted: Tue Jan 09, 2018 8:38 pm    Post subject:
osgUtil::IntersectionVisitor eats all the memory
Reply with quote

Hi Nick,

There isn't anyone else other than you can debug this one - you are
the only one with your data and with your application code, you are
the only one seeing this issue, we'd have to be omnipresent to be able
to pinpoint what is wrong.

As I said the best thing you can do is run your application and your
data within a debugger and then break it when it starts to consume
memory/spin the CPUI. You might need to break/restart a few times to
get a clear picture of where things are going amiis.

Robert.

On 9 January 2018 at 12:31, Trajce Nikolov NICK
<> wrote:
Quote:
Thanks Robert,

no circular reference since I am displaying that database in the viewer
nicely. Here is the struct (a bit odd but it is as is):

Group
|
PagedLOD PagedLOD PagedLOD .... dozen of these
|
Quadtree (similar to VPB generated subtiles)

I was thinking the visitor is reading all of these by reading all of these
PagedLODs without taking the account the range from the eyepoint. So while
debuging I tried this:

struct MyIntersectionVisitor : public osgUtil::IntersectionVisitor
{
MyIntersectionVisitor(float range)
: IntersectionVisitor()
, _range(range)
{
}

virtual void apply(osg::PagedLOD& plod)
{
if (getDistanceFromEyePoint(plod.getCenter(), true) < _range)
{
osgUtil::IntersectionVisitor::apply(plod);
}
}

protected:
float _range;
};

but no luck. Is there a way to flush all the pending and loaded nodes from
the DatabasePager?

On Tue, Jan 9, 2018 at 1:23 PM, Robert Osfield <>
wrote:
Quote:

Hi Nick,

This is really something you'd want to use a debug for - just run it
and break the app before anything untoward happens.

The code itself looks quite benign on a first reading, the only thing
I can think of that might cause a memory issue would be if your scene
graph had a circular reference in it so the traversal ends up in an
infinite loop.

Robert

On 9 January 2018 at 12:12, Trajce Nikolov NICK
<> wrote:
Quote:
hi Robert, Community,

I have the following code in a loop against very large quadtree based
database. And this code is eating all the memory, progressively and then
the
system kills it . Any clue?

Thanks a lot

osg::ref_ptr<osgUtil::LineSegmentIntersector> picker;
osg::ref_ptr<osgUtil::IntersectionVisitor> iv;

osg::Vec3d getHOT(const osg::Vec3d& position,
osgViewer::CompositeViewer&
viewer, osg::Vec3& normal, bool& valid)
{
osg::Vec3d result;

osg::EllipsoidModel em;
osg::Vec3d up = em.computeLocalUpVector(position.x(), position.y(),
position.z());
up.normalize();

osg::Vec3d s = position + up * 100;
osg::Vec3d e = osg::Vec3d(0, 0, 0);

if (viewer.getView(0)->getSceneData())
{
#if 1
if (!picker.valid())
{
picker = new osgUtil::LineSegmentIntersector(s,e);
iv = new MyIntersectionVisitor(RANGE);
}
picker->setStart(s);
picker->setEnd(e);
picker->getIntersections().clear();
iv->setIntersector(picker);
iv->reset();
iv->setUseKdTreeWhenAvailable(false);

//iv->setLODSelectionMode(osgUtil::IntersectionVisitor::USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION);
viewer.getView(0)->getSceneData()->accept(*iv);

if (picker->containsIntersections())
{
osgUtil::LineSegmentIntersector::Intersections hitList =
picker->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator hit =
hitList.begin();

result = hit->getWorldIntersectPoint();
normal = hit->getWorldIntersectNormal();
valid = true;

return result;
}
#endif
}
valid = false;

return result;
}

--
trajce nikolov nick








--
trajce nikolov nick





------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Leaking memory on node removal Tini General 1 Fri May 25, 2018 6:48 pm View latest post
No new posts Leaking memory on node removal Tini General 0 Fri May 25, 2018 6:39 pm View latest post
No new posts Leaking memory on node removal Tini General 0 Fri May 25, 2018 6:30 pm View latest post
No new posts Leaking memory on node removal Tini General 0 Fri May 25, 2018 6:27 pm View latest post
No new posts How do I create a graphics context on... srinivas General 3 Tue Apr 24, 2018 11:40 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP