Memory Leak?

Topics: Developer Forum, User Forum
Mar 5, 2013 at 8:49 PM
Hey guys,

So I'm working on a game that involves the player shooting a lot of projectiles. When I first wrote the code, I used the World.RemoveBody method to remove them successfully after 10 seconds just so there aren't thousands of bodies flying around past their relevancy. However, after firing a couple hundred-thousand of them, the game grinds to a halt. The bodies is down to the 3 bodies I started with (2 objects, 1 player), and the menu that comes up when F2 is pressed and the graph say there are a ton of calculations being done, and I don't know what this means. Is there something I'm missing?
Mar 5, 2013 at 9:40 PM
This is just a guess, but are you subscribing to any events on your projectiles (like OnCollision)? If so, are you unsubscribing before you RemoveBody? If an object has event subscribers attached to it, it can prevent the GC from cleaning it up -- memory leak.

Hope that helps,