Just like any actor, a restartable actor can free persistent memory blocks using pmmFree() or pmmFreeAll(). This is described in "3.4.2 Freeing a Persistent Memory Block Explicitly".
Restartable actors which allocate memory with pmmAllocate() can also use a simple, automatic de-allocation mechanism provided by the Hot Restart Controller. This saves the actor from having to free its persistent memory explicitly. Instead, the persistent memory will remain allocated for the lifetime of the actor's group, and then be freed automatically by the Hot Restart Controller when the last member of the actor's restart group terminates cleanly. The disadvantage of this system is that the lifetime of the restart group may extend well beyond the point at which the memory block is no longer needed. In this case the memory block will take up space in persistent memory unnecessarily.
To mark a persistent memory block for automatic de-allocation by the
Hot Restart Controller, pass the macros HR_GROUP_KEY
and HR_GROUP_KEYSIZE
as the delKey and delKeySize arguments respectively
in the call to pmmAllocate(). These macros tie the lifetime
of the persistent memory block to the lifetime of the calling actor's restart
group.
A block marked for automatic de-allocation by the Hot Restart Controller
can still be freed explicitly by calling pmmFree() with
the block's PmmName. However, attempting to call pmmFreeAll() by passing the HR_GROUP_KEY
and HR_GROUP_KEYSIZE
macros will result in an error,
as this is not permitted.