10. MV (Manual Variable)¶
Deprecated
starting with version 1.111.
MVFF (Manual Variable First Fit) or MVT (Manual Variable Temporal) should be used instead.
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 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.
10.2. MV interface¶
#include "mpscmv.h"
-
mps_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()
may take three keyword arguments:MPS_KEY_EXTEND_BY
(typesize_t
, default 65536) is the size of segment 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.MPS_KEY_MAX_SIZE
(typesize_t
, default 65536) is the predicted maximum size of blocks that will be allocated from the pool.
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);
Deprecated
starting with version 1.112.
When using
mps_pool_create()
, pass the segment size, mean size, and maximum size like this:mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena, mps_class_t mps_class_mv(), size_t extend_size, size_t average_size, mps_size_t maximum_size)
-
mps_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 four keyword arguments: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_debug_option_s
.Deprecated
starting with version 1.112.
When using
mps_pool_create()
, pass the debugging options, segment size, mean size, and maximum size like this:mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena, mps_class_t mps_class_mv_debug(), mps_debug_option_s debug_option, mps_size_t extend_size, mps_size_t average_size, mps_size_t maximum_size)
10.3. MV introspection¶
#include "mpscmv.h"
-
size_t
mps_mv_free_size
(mps_pool_t pool)¶ Return the total amount of free space in an MV pool.
pool
is the MV pool.Returns the total free space in the pool, in bytes (1).
-
size_t
mps_mv_size
(mps_pool_t pool)¶ Return the total size of an MV pool.
pool
is the MV pool.Returns the total size of the pool, in bytes (1). This is the sum of allocated space and free space.