Asymptotically Optimal Hypothesis Testing with Memory Constraints