Backport the part of 505868f421db which fixes ram_bytes when requeueing an in-memory message to delta, and do the same for beta.
Minor refactor.
Merge bug26498