NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.35k stars 274 forks source link

Leak: Interaction Marker Pool #11

Closed rknoesel closed 7 years ago

rknoesel commented 7 years ago

While in a level, the size of NPhaseCore::mInteractionMarkerPool continues to increase over time. After 15 mins or so, we're looking at > 2^16 elements. This cleans itself up when we leave the level and all PhysX actors are released. Our test case has about 32 rigid dynamics bouncing around and probably another 32 moving rigid kinematics. Lots of rigid statics.

Concurrently, we have an ActorSim whose mInteractions end up exceeding 65535, which causes a crash due to issue #12

kstorey-nvidia commented 7 years ago

I've instrumented the code and I couldn't find an obvious memory leak. I set up a scene with a number of balls bouncing on a plane falling from different heights with restitution 1. The filter shader was set to suppress all ball-ball interactions but to permit ball-ground interactions so the balls kept bouncing up/down through each-other finding/losing pairs in the broad phase, while I kept track of the size of the interaction marker pool. It grew when new pairs were detected by the broad phase and shrank when pairs were lost by the broad phase. It seemed to me that it was correctly tracking the number of interactions.

Is it expected/valid that there are in excess of 64k interactions in your scene? Interactions are recorded on a shape-shape basis so you may not need a lot of actors if you have a large number of shapes per-actor.

Could you provide a PVD capture so I can more closely match your use-case to see if there's a bug I wasn't able to repro with my simple scene?

Also, please be aware that using eSUPPRESS is only useful if you plan on adjusting your filtering rules and re-filtering interactions at some point during your simulation. If you don't plan on doing this, killing the interactions using eKILL is usually a better option.

rknoesel commented 7 years ago

Ahh yes, I was using PxFilterFlag::eSUPPRESS in my simulation filter shader. Changing this to PxFilterFlag::eKILL solved the issue.

Thanks!!