Original Post
I was wondering what the best way of handling potentially thousands of throwaway objects being created and destroyed each frame. I would think that it would be rather inefficient and cause memory thrashing and would rather be avoided. Maybe I should explain some of my intent and see what you guys might have to say. I was considering trying to make a multi-threaded game engine with graphics as one thread, physics for another, game entities grouped into 4 to 6 threads, etc. When a game entity needs to update some aspect of the graphics I thought of creating command objects (owning data necessary for its task and overriding an exec() function) that can be pushed onto a queue in the graphics thread where the graphics thread can call these commands when it's ready to then get rid of them. It makes me feel a little uncomfortable creating and destroying so many objects so rapidly and I assume it would not be very efficient. Do you guys have any thoughts on this? Maybe there is a way to make sure memory is not thrashed about too badly? Thanks.