### Navigation

- index
- next |
- previous |
- Memory Pool System 1.111.0 documentation »
- Pool reference »

# 9. MFS (Manual Fixed Small)

MFS is an manually managed pool class for small objects of fixed size.

Unlike other manual pool classes, it is not subject to internal fragmentation.

The implementation is very simple: unlike other pool classes which store their control structures separately from the allocated blocks, MFS maintains a stack of free blocks using a pointer in the free block. `mps_alloc()` pops this stack and `mps_free()` pushes it.

## 9.1. MFS properties

- Supports allocation via `mps_alloc()` and deallocation via `mps_free()`.
- Does not support allocation via allocation points.
- Does not support allocation frames.
- Supports segregated allocation caches (but using one would be pointless, since all blocks are the same size).
- There are no garbage collections in this pool.
- Blocks may not contain references to blocks in automatically managed pools (unless these are registered as roots).
- Allocations are fixed in size.
- The alignment of blocks is not configurable: it is the natural alignment of the platform (see `MPS_PF_ALIGN`).
- Blocks do not have dependent objects.
- Blocks are not automatically reclaimed.
- Blocks are not scanned.
- Blocks are not protected by barriers(1).
- Blocks do not move.
- Blocks may not be registered for finalization.
- Blocks must not belong to an object format.

## 9.2. MFS interface

    #include "mpscmfs.h"

mps_class_t `mps_class_mfs`(void)

  Return the pool class for an MFS (Manual Fixed Small) pool.

  When creating an MFS pool, `mps_pool_create()` takes two extra arguments:

      mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena,
                                mps_class_t mps_class_mfs(),
                                mps_size_t extend_size,
                                mps_size_t unit_size)

  `extend_size` is the size of segment that the pool will request from the arena. It must be at least as big as `unit_size`. If this is not a multiple of `unit_size`, there will be wasted space in each segment.

  `unit_size` is the size of blocks that will be allocated from this pool, in bytes(1). It must be at least one word.

### Navigation

- index
- next |
- previous |
- Memory Pool System 1.111.0 documentation »
- Pool reference »