14.2 allocating new garbage?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Sigil
Posts: 6
Joined: Fri Jun 18, 2010 8:06 pm

14.2 allocating new garbage?

Post by Sigil »

I recently upgraded my engine and physics .dll's to XNA 4.0 and Bepu 14.2. Previously, one of my test scenes was generating no memory usage whatsoever after reaching steady running state. Now, it's generating something on the order of 40 bytes per frame. Specifically, it's allocating BEPUPhysics.HashSet<T>.Enumerators from within the SimulationIsland.TryToDeactivate() method, with call stack

Space.Update->Space.UpdateWithInternalTimeStepsMultithreaded->Space.UpdateDiscreteMultithreaded->Space.SleepPulse

I haven't looked at it in reflector yet, but it looks offhand like you have a method enumerating an IEnumerable that has a value type enumerator, which will generate unnecessary garbage. Oddly, I never encountered this in 14.1 or earlier. Thoughts?

Edit: Yeah, looking at it in more detail, it's almost certainly your implementation of the new HashSet<T> emulator. You might take a closer look at that in your next change set.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: 14.2 allocating new garbage?

Post by Norbo »

That's interesting, I don't recall making any changes there. I'll take a look, thanks for the report.
Sigil
Posts: 6
Joined: Fri Jun 18, 2010 8:06 pm

Re: 14.2 allocating new garbage?

Post by Sigil »

I can send you a sample project if you'd like, but it should be fairly straightforward to see it in the CLR Profiler on even a simple test scene.
Post Reply