Box2D Forums

It is currently Sat May 25, 2013 7:12 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Memory Question
PostPosted: Tue Aug 03, 2010 6:57 am 
Offline

Joined: Thu Apr 15, 2010 10:33 am
Posts: 13
Hi,

Does the Step function in b2World, take up a lot of memory over time? I'm finding that after playing my game after a few minutes it causes all of the objects to stick to one another rather than bounce. The sticking only lasts parts of seconds but it's noticible enough to cause problems.

Is there something I'm not doing properly?
Any help would be appreciated.
Alex.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Tue Aug 03, 2010 8:15 am 
Offline

Joined: Fri Apr 17, 2009 9:01 pm
Posts: 143
Unless there's a bug in Box2D, repeated calls to Step() shouldn't result in steadily increasing memory usage (I wouldn't think).

How do you know that memory usage is increasing? It seems a little odd to associate objects sticking together in Box2D with increased memory usage (unless you're talking about framerate hitching or something like that).

In any case, there are plenty of other ways to leak memory, so if you know that memory usage is increasing over time, it may be due to some other part of your code.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Tue Aug 03, 2010 9:24 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
Box2D uses a high water-mark for memory allocation. So if you ever allocate 200 bodies, Box2D will retain space for 200 bodies, even if you reduce the body count to 100.

Besides that, I have not seen any reports of leaks in Box2D. You should try to instrument the allocator to test your theory.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Tue Aug 03, 2010 9:55 am 
Offline

Joined: Thu Apr 15, 2010 10:33 am
Posts: 13
I'm not using that many bodies. Max is 10. I have them floating around in no gravity, with one that I control with my mouse. So when I go hit them around with my mouse controlled body, after a while it starts to lag (just the motion of the bodies) not the actual program. It seems that it's just taking longer to process after a while. Any reason that this may happen? I'm just speeculating that it's memory. Not entirely sure it is.

Thanks again.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Tue Aug 03, 2010 9:58 am 
Offline

Joined: Thu Apr 15, 2010 10:33 am
Posts: 13
Sorry just to follow up. It starts to happen a lot after there are two objects that just brush up against one another. After that happens once, it causes most collisions to lag. The collisions that seem to lab are the ones that are slower speed collisions. The high speed collisions work well.

Thanks


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Tue Aug 03, 2010 3:01 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
It sounds like an older version of continuous collision. Try turning that off. The most recent code in SVN doesn't stall for continuous collision events.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Wed Aug 04, 2010 12:01 pm 
Offline

Joined: Thu Apr 15, 2010 10:33 am
Posts: 13
Hi,

I am using v2.0.1, v2.1 was released after I had a lot of major code written and I tried to implement it and it caused a lot of problems so I had to keep it in v2.0.1

How do I turn off continuous collisions?

Thanks


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Thu Aug 05, 2010 11:14 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
There should be a function on b2World that allows you to turn off continuous physics.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Mon Aug 09, 2010 12:23 pm 
Offline

Joined: Thu Apr 15, 2010 10:33 am
Posts: 13
Hi Erin,

I found where you turn off the CCD but once I do that, the collision detection is much worse. Is there any way to fix my prior problem without switching over to v2.1? Or is that my only option.

Any help would be appreciated.
Alex.


Top
 Profile  
 
 Post subject: Re: Memory Question
PostPosted: Mon Aug 09, 2010 7:33 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
I really have no idea what your actual problem is. Can you show a video or reproduce the problem in the testbed?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


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 post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group