Use physmem and realmem from get_memory() in the appropriate places

Backport to 2.1