10. MV (Manual Variable)¶
MV is a general-purpose manually managed pool class that manages blocks of variable size.
10.1. MV properties¶
Supports allocation via
mps_alloc()
and deallocation viamps_free()
.Does not support allocation via allocation points.
Does not support allocation frames.
Supports segregated allocation caches.
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 may be variable in size.
The alignment of blocks is configurable.
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.
10.2. MV interface¶
#include "mpscmv.h"
-
mps_pool_class_t
mps_class_mv
(void)¶ Return the pool class for an MV (Manual Variable) pool.
When creating an MV pool,
mps_pool_create_k()
takes four optional keyword arguments:MPS_KEY_ALIGN
(typemps_align_t
, default isMPS_PF_ALIGN
) is the alignment of the addresses allocated (and freed) in the pool. The minimum alignment supported by pools of this class is 1 (one) and the maximum is the arena grain size (seeMPS_KEY_ARENA_GRAIN_SIZE
).MPS_KEY_EXTEND_BY
(typesize_t
, default 65536) is the size of block that the pool will request from the arena.MPS_KEY_MEAN_SIZE
(typesize_t
, default 32) is the predicted mean size of blocks that will be allocated from the pool. This value must be smaller than, or equal to, the value forMPS_KEY_EXTEND_BY
.MPS_KEY_MAX_SIZE
(typesize_t
, default 65536) is the predicted maximum size of blocks that will be allocated from the pool. This value must be larger than, or equal to, the value forMPS_KEY_EXTEND_BY
.
The mean and maximum sizes are hints to the MPS: the pool will be less efficient if these are wrong, but nothing will break.
For example:
MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_MEAN_SIZE, 32); MPS_ARGS_ADD(args, MPS_KEY_MAX_SIZE, 1024); MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, 1024 * 1024); res = mps_pool_create_k(&pool, arena, mps_class_mfs(), args); } MPS_ARGS_END(args);
-
mps_pool_class_t
mps_class_mv_debug
(void)¶ A debugging version of the MV pool class.
When creating a debugging MV pool,
mps_pool_create_k()
takes five optional keyword arguments:MPS_KEY_ALIGN
,MPS_KEY_EXTEND_SIZE
,MPS_KEY_MEAN_SIZE
,MPS_KEY_MAX_SIZE
are as described above, andMPS_KEY_POOL_DEBUG_OPTIONS
specifies the debugging options. Seemps_pool_debug_option_s
.