Question

I was reading up on object recycling namely, that done by flixel. The article I was reading is here, in case you were interested as I was.

I started to think about how I could integrate a similar system into my entity-component based framework, EntityEngine. I'm not sure if it's necessarily plausible, integrating it in the way that flixel does it doesn't seem to have any effect on frame rate, cpu/ram usage, etc. I'm pretty sure this has to do with the fact that each Entity is a HashSet<Component>.

The way flixel handles object recycling is, each object has a defined set of fields, something that an entity does not, by design. When an object is "destroyed" it is not removed from the base array but, kept in and toggled to let the framework know that that object can be overwritten and should no longer be updated and drawn. However, I'm pretty sure the inherited collection is a problem here.

So the question is, can I use object recycling to improve framerate/cpu usage or, am I out of luck?

EDIT: I am using .Net 4 with XNA 4 refresh.

Was it helpful?

Solution

Recycling entities/components only affects to framerate/cpu usage if you have problems with the garbage collector.

When the garbage collector recollects unreferenced objects causes a framerate down, it is the reason to keep the objects referenced in a pool and reuse them, avoiding the garbage collector to be launched too often and with less work load.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top