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

Frame Pooling vs Frame Inheritance

Feb 23, 2012 at 1:05 PM
Edited Feb 23, 2012 at 1:13 PM

This is a discussion regarding the option of using frame inheritance (Where each frame type is a different class that inherits from a base frame class and new frames are allocated and destroyed as required) or using frame pooling. (Where every frame is of the same type, but frames are only ever allocated once into a pool and after use they are recycled by resetting them and putting them back into the frame pool for re-use.)

The argument for frame inheritance is based upon the code maintainability, ease of use (Where you have a class which represents the frame's data exactly.) and general OOP methodology.

The argument for frame pooling is based upon performance (Specifically garbage collector performance.) and the limited memory resources on micro controllers. Static methods on the frame can be used to help decode each message type to reduce repetition of code.


The Lidgren network library has a nice example of variable-size messages which are still pooled:


I will continue my sample project and try to come up with a nice all-round solution to the problems faced by frame pooling.


The previous discussion on this topic can be seen from this post onwards: