This project has moved. For the latest updates, please go here.

Frame Pooling vs Frame Inheritance

Developer
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:

http://code.google.com/p/lidgren-network-gen3/source/browse/branches/nn/Lidgren.Network/NetPeer.Recycling.cs

 

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:

http://www.tinyclr.com/forum/21/5553/#/8/msg57706