Simulation limits with lots of bodies?

I'm having a problem. I have dozens of balls falling down a Box2D 2.02 stage. But when I hit a certain threshold of shapes, the simulation starts to act very predictably *wrong*. Basically, I have dozens of marbles falling down a maze. But once too many hit the screen, marbles will start straying to an alternate course - until the screen clears itself a little, then it's fine again.

So clearly, I'm hitting some mathematical threshold in Box2D, after which the simulation starts skipping steps or something. The chunk of my code I've noticed it hitting most often has only one Box2D call - ApplyImpulse. The call has constants in it, so it's not something I'm changing.

So - what is the threshold in Box2D that I'm hitting that makes ApplyImpulse give a different result?
Ther'es no step skipping. THe main threshold of note is pair/proxy counts in the broadphase, but hitting those tends to fail catastrophically. How many shapes are you adding.
Hi, I'm falling on the same issue. I can't place more than 504 shapes in a body, or no more than 504 bodies in the world. Does exist some way to sorting out this problem?
Thanks,
Look in the b2Settings file for maxProxies. 'Proxy' applies to the number of shapes you can have, and it's set by default to 512. Increase that, and you increase the number of shapes you can have.

The next setting is max pairs. In theory, the maximum you would ever need would be one for each possible pairing of shapes. For 512, that's... 512*511/2 (Or 130816 pairings). In practice most games can get away with this being significantly lower.

Beware though - on a b2world build, all 512 proxies are instantiated. Increase that number too high and it will take several seconds to build a world, and use a huge chunk of memory on your user's computers.

Also, Boris - I significantly reduced my own maxProxies and maxPairs in my engine and have not since seen the simulation breaking bug I was encountering randomly before. If I do, however, I have a means now of being able to capture it and reproduce it, and I'll bring it back here for reporting.
k

Original thread: https://box2d.org/forum/viewtopic.php?t=4723