Asymptotic optimality of finite memory detection