Mark-compact algorithm