This project has moved and is read-only. For the latest updates, please go here.

Garbage with Collision/Separation Event Handlers

Jul 9, 2009 at 9:56 PM
Edited Jul 10, 2009 at 4:13 AM

Hey guys, I'm at the stage in my project where I'm trying to optimize my code so I've been running the game on xbox and pc with various profilers. It runs like a dream on pc but on xbox it goes from 60fps to 2-4fps within 10 seconds of starting the game. So I ran the CLR profiler on the game and noticed that 90% of my garbage was coming from the CollisionEventHandler and SeparationEventHandler. I looked into that a bit more and it seems that the average size of the garbage is only about 32bytes but it gets created every single collision/separation call so there are about 50,000 instances of it within a short time playing which seems to explain why the game starts out great and then quickly becomes unplayable. Also, in the allocation graph, a lot of the garbage related to the collision/separation passes through Delegate::Combine (which is the += operater i believe) I'm not sure if thats part of the problem?

I haven't seen any discussion threads related to CollisionEventHandler and SeparationEventHandler garbage so I hope this is just my implementation error or something that can be easily fixed. 


EDIT: FIXED- I'm apparently not very familiar with events haha, I was subscribing to the OnCollision and OnSeparation EVERY UPDATE...