Most Unity developers are aware that instantiating and destroying GameObjects repeatedly is something to avoid because it generates some garbage. But a discussion came up about whether it's more efficient to pool regular C# classes (non-GameObject types) that are instantiated and released frequently. It came up in relation to a discussion about an RTS game using the Command Pattern for Unit orders, which is when commands are queued and executed by the units in the game. Over the course of gameplay you can expect that Commands (implementing an ICommand interface) will be created and destroyed a good bit:
unit.Commands.Enqueue( new MoveCommand( goal, MovementSpeed.Fast );
The command gets executed by a CommandProcessor and then when IsFinished or Cancel is true it's set to null and the processor dequeues the next one and runs it.
Is there any benefit to pooling regular C# classes like this in a game? From what I see on Microsoft's documentation, it only recommends pooling objects that are expensive to create and destroy (Unity GameObjects being a prime example). Commands in the game don't consume any native resources (and don't need to implement IDisposable) and they are pretty lightweight, usually just holding a few Vector3 positions, a reference to a Unit or group and a few properties like IsFinished and Cancel.
My position in the debate is that they don't need to be pooled, that the CLR handles all of this just fine and that pooling should be reserved for rapid creation/destruction of GameObjects and anything that consumes native resources, has an expensive initialization and destruction process or generates any type of "garbage" that's left behind. However, I've never really considered this before and I'm not really sure where else to find more in-depth information about the topic. I really just want to know if this is even worth considering/doing and how I can explain to others why it is or isn't.
EDIT: I also think pooling commands and similar things might be less efficient than allowing the CLR to do its thing because we will constantly have more memory than necessary allocated to store the pool in RAM ... any thoughts?