Following conditions need to be met to make the C heap serializable:
- get start of allocation from offset pointer
- get size of allocation
- addresses appearing in allocation must be tagged as pointers (1:64 metadata)
- associate foreign pointers/allocations with plugins; the simplest is dlsym, but there's also file handles, graphics resources, JIT functions, stack vars etc.
(4) is what makes the whole affair very interesting.
above conditions also make it possible to run a GC. it is also possible to perfectly deduplicate the heap in subquadratic time, to validate pointers, guard against bad load/stores & to merge different heaps.