-
Notifications
You must be signed in to change notification settings - Fork 881
v1_2_zone
A zone is an object that manages allocations and deallocations of memory during packing and unpacking. Assigning serialization of objects to a particular zone, means that those memory allocations and deallocations may be treated as a group.
This permits you to implement advanced memory management strategies, such as assigning each serialized object to its own memory pool, or permitting certain types of serialized objects to share memory pools.
Two zone implementations currently exist, one for C++03 and one for C++11.
A zone can handle allocations of both aligned and non-aligned memory, with its allocate_aligned()
and allocate_non_aligned()
member functions. Additionally, it provides static new()
and delete()
operators, as well as allocate() functions for objects that handle any reasonable number of parameters.
Additionally, a zone can store a set of "finalizer" functors. You can provide these finalizers via the push()
member function, which expects parameters for both the function as well as the parameter to be provided to that function. The zone stores both a pointer to a function as well as to data that should be provided as a parameter to that function. When the zone is destroyed, each of the finalizers are called in sequence. This permits you to implement release of arbitrary memory and other resources at teardown time.
Internally, the current msgpack C++ implementations use ::malloc()
, ::realloc()
, and ::free()
. However, you may wish to subclass or otherwise rewrite these zone implementations, in order to rely on a memory management system of your preference.
-
Home
- Q&A
- v2.0.x or later
- v1.1.x - v1.4.x
- v1.0.x