.. highlight:: none


.. index::
   pair: MFS pool class; design
   single: pool class; MFS design

.. _design-poolmfs:


MFS pool class
==============

.. mps:prefix:: design.mps.poolmfs
   pair: MFS pool class; design
   single: pool class; MFS design


Overview
--------

MFS stands for "Manual Fixed Small". The MFS pool class manages
objects that are of a fixed size. It is intended to only manage small
objects efficiently. Storage is recycled manually by the client
programmer.

A particular instance of an MFS Pool can manage objects only of a
single size, but different instances can manage objects of different
sizes. The size of object that an instance can manage is declared when
the instance is created.


Implementation
--------------

:mps:tag:`impl.extents` MFS operates in a very simple manner: each extent
allocated from the arena is divided into units.

:mps:tag:`impl.free-units` Free units are kept on a linked list using a
header stored in the unit itself. The linked list is not ordered;
allocation and deallocation simply pop and push from the head of the
list. This is fast, but successive allocations might have poor
locality if previous successive frees did.

:mps:tag:`impl.extent-ring` The list of extents belonging to the pool is
maintained as a ring with a node at the start of each extent.

:mps:tag:`impl.extent-ring.justify` Storing the linked list of free nodes
and the extent ring node in the managed memory is against the general
principle of the MPS design, which keeps its management structures
away from client memory. However, the MFS pool is used during the
bootstrapping process (see design.mps.bootstrap.land.sol.pool_) and so
has no other memory pools available for storage.

.. _design.mps.bootstrap.land.sol.pool: bootstrap.html#design.mps.bootstrap.land.sol.pool