AMC is a general-purpose automatically managed pool class. This is the most mature pool class in the MPS, intended for the majority of objects in the client program. Use this pool class unless you need a particular feature that it doesn’t provide.
“Mostly Copying” means that it uses copying garbage collection except for blocks that are pinned by ambiguous references.
It uses generational garbage collection. That is, it exploits assumptions about object lifetimes and inter-connection variously referred to as “the generational hypothesis”. In particular, the following tendencies will be efficiently exploited by an AMC pool:
In the pool’s generation chain, specify the capacity and mortality of generations 0 to n−1. Survivors from generation n−1 get promoted into an arena-wide “top” generation.
#include "mpscamc.h"
Return the pool class for an AMC (Automatic Mostly-Copying) pool.
When creating an AMC pool, mps_pool_create_k() requires two keyword arguments:
For example:
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
MPS_ARGS_DONE(args);
res = mps_pool_create_k(&pool, arena, mps_class_amc(), args);
} MPS_ARGS_END(args);
Deprecated
starting with version 1.112.
When using mps_pool_create(), pass the format and chain like this:
mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena,
mps_class_t mps_class_amc(),
mps_fmt_t fmt,
mps_chain_t chain)
#include "mpscamc.h"
Visit all formatted objects in an AMC pool.
pool is the pool whose formatted objects you want to visit.
f is a function that will be called for each formatted object in the pool.
p and s are arguments that will be passed to f each time it is called. This is intended to make it easy to pass, for example, an array and its size as parameters.
It is an error to call this function when the arena is not in the parked state. You need to call mps_arena_collect() or mps_arena_park() before calling mps_amc_apply().
The function f will be called on both client and padding objects. It is the job of f to distinguish, if necessary, between the two. It may also be called on dead objects that the collector has not recycled or has been unable to recycle.
Note
There is no equivalent function for other pool classes, but there is a more general function mps_arena_formatted_objects_walk() that visits all formatted objects in the arena.
Note
This function is intended for heap analysis, tuning, and debugging, not for frequent use in production.
The type of a stepper function for formatted objects in an AMC pool.
addr is the address of an object in the pool.
p and s are the corresponding arguments that were passed to mps_amc_apply().
The function may not call any function in the MPS. It may access:
It must not access other memory managed by the MPS.