check_memory: separate out a malloced state